code4craft / code4craft/xsoup

Not support node array select. xpath("span[2]/small/text()")

Open
#34 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
474
Forks
148
PR merge metrics
No merged PRs in 30d

Description

Not support node array select. "span[2]"

Example:
page.getHtml().xpath("span[2]/small/text()");

XPathParser.java add code, I suggest:
private Evaluator consumePredicates(String queue) {
// +++ start add code ++++
if(StringUtils.isNumericSpace(queue)) {
return new XEvaluators.IsNthOfType(0, Integer.parseInt(queue.trim()));
}
// +++ end add code ++++
XTokenQueue predicatesQueue = new XTokenQueue(queue);
EvaluatorStack evaluatorStack = new EvaluatorStack();
Operation currentOperation = null;
predicatesQueue.consumeWhitespace();
while (!predicatesQueue.isEmpty()) {
...
}

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in XPathParser.java, focusing on consumePredicates and the handling of numeric predicate text. Reproduce page.getHtml().xpath("span[2]/small/text()") and verify that the result selects the second span and its small text; existing parser tests should confirm the behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.