code4craft / xsoup

When jsoup meets XPath.
MIT License
469 stars 151 forks source link

Valid xpath crashes the lib with NPE #29

Open krzysztofus opened 7 years ago

krzysztofus commented 7 years ago

Example xml snippet:

NoLuck NoHit
whatever ShouldHit
Again NoHit

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)