Xsoup cannot compile valid xpath expression / ()[1] / first element
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 474
- Forks
- 148
- PR merge metrics
- No merged PRs in 30d
Description
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)
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in Xsoup.compile and XPathParser.java, especially findElements and combinator, and reproduce the reported selector (div[@class="fh-breadcrumb"])[1]//li. Trace how grouped XPath expressions and positional predicates are parsed. Done means the selector compiles and returns the first matching element's li nodes without the reported SelectorParseException.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100