Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Valid xpath crashes the lib with NPE #29

Open
krzysztofus opened this issue Feb 20, 2017 · 0 comments
Open

Valid xpath crashes the lib with NPE #29

krzysztofus opened this issue Feb 20, 2017 · 0 comments

Comments

@krzysztofus
Copy link

krzysztofus commented Feb 20, 2017

Example xml snippet:

<tbody>
    <tr>
        <td>NoLuck</td>
        <td>
            <span>NoHit</span>
        </td>
    </tr>
    <tr>
        <td>whatever</td>
        <td>
            <span>ShouldHit</span>
        </td>
    </tr>
    <tr>
        <td>Again</td>
        <td>
            <span>NoHit</span>
        </td>
    </tr>
</tbody>

XPath:
//table/tbody/tr[contains(td,'whatever']/td/span/text()

It should return: ShouldHit as verified with w3cSchool online tool.
Instead it throws NullPointerException:

Exception in thread "main" java.lang.NullPointerException
at us.codecraft.xsoup.xevaluator.CombiningEvaluator$And.matches(CombiningEvaluator.java:53)
at us.codecraft.xsoup.xevaluator.CombiningEvaluator$And.matches(CombiningEvaluator.java:53)
at us.codecraft.xsoup.xevaluator.StructuralEvaluator$ImmediateParent.matches(StructuralEvaluator.java:84)
at us.codecraft.xsoup.xevaluator.CombiningEvaluator$And.matches(CombiningEvaluator.java:53)
at us.codecraft.xsoup.xevaluator.StructuralEvaluator$ImmediateParent.matches(StructuralEvaluator.java:84)
at us.codecraft.xsoup.xevaluator.CombiningEvaluator$And.matches(CombiningEvaluator.java:53)
at org.jsoup.select.Collector$Accumulator.head(Collector.java:42)
at org.jsoup.select.NodeTraversor.traverse(NodeTraversor.java:31)
at org.jsoup.select.Collector.collect(Collector.java:24)
at us.codecraft.xsoup.xevaluator.DefaultXPathEvaluator.evaluate(DefaultXPathEvaluator.java:29)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant