Skip to content

Misinformation of getByXPath method #52

Description

@TomasTokaMrazek

JavaDoc states: "Evaluates the specified XPath expression from this node, returning the matching elements."

That implies, that with given html

<html>
<body>
    <h1>Wrong</h1>
    <div>
        <h1>Right</h1>
    </div>
<body>
</html>

and selected div node, in order to select child h1 node we need to pass xpath as //h1. But that's not the case, we need to select current node first with a dot selector, so correct xpath is .//h1. While it is proper xpath, I'd argue, that JavaDoc implies, that the node is already selected. It's specially confusing, if you print node as xml and try to validate your xpath via third party tools.

It's a bit against common sense, that selected node does not traverse from it's location. I do not expect change in the code, but more specific JavaDoc would be definitely helpful.

No activity

Activity on this issue will appear here.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions