code4craft / xsoup

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

Xsoup cannot compile valid xpath expression / ()[1] / first element #25

Open timactive opened 8 years ago

timactive commented 8 years ago

I need only the first element for a selector (div[@class="fh-breadcrumb"])[1]. This expression work fine in chrome browser.

page.getHtml().xpath("//(div[@class=\"fh-breadcrumb\"])[1]//li").nodes();

But when i try i have this exception linked to Xsoup :

org.jsoup.select.Selector$SelectorParseException: Could not parse query '(div[@class="fh-breadcrumb"])[1]': unexpected token at '(div[@class="fh-breadcrumb"])[1]' at us.codecraft.xsoup.xevaluator.XPathParser.findElements(XPathParser.java:166) ~[xsoup-0.3.1.jar:na] at us.codecraft.xsoup.xevaluator.XPathParser.parse(XPathParser.java:76) ~[xsoup-0.3.1.jar:na] at us.codecraft.xsoup.xevaluator.XPathParser.parse(XPathParser.java:408) ~[xsoup-0.3.1.jar:na] at us.codecraft.xsoup.xevaluator.XPathParser.combinator(XPathParser.java:110) ~[xsoup-0.3.1.jar:na] at us.codecraft.xsoup.xevaluator.XPathParser.parse(XPathParser.java:74) ~[xsoup-0.3.1.jar:na] at us.codecraft.xsoup.xevaluator.XPathParser.parse(XPathParser.java:408) ~[xsoup-0.3.1.jar:na] at us.codecraft.xsoup.Xsoup.compile(Xsoup.java:25) ~[xsoup-0.3.1.jar:na]

Sorry i not view you have specific project for Xsoup.(so dupplicate with issue https://github.com/code4craft/webmagic/issues/339)