Git Product home page Git Product logo

Comments (9)

0crat avatar 0crat commented on June 30, 2024

@yegor256/z please, pay attention to this issue

from jcabi-xml.

yegor256 avatar yegor256 commented on June 30, 2024

@piotrkot this is because the root node is not changed, when you retrieve nodes.get(1). Your root is still <root>

from jcabi-xml.

0crat avatar 0crat commented on June 30, 2024

Job gh:jcabi/jcabi-xml#154 is not assigned, can't get performer

from jcabi-xml.

piotrkot avatar piotrkot commented on June 30, 2024

@yegor256 I would like to have it reopened. I had no time to react to your comment.

Let me explain the problem.
Based on the provided XML, all "a" nodes are found with doc.nodes("//a").
This indeed finds two "a" nodes, and List<XML> nodes list contains two XML elements.
With nodes.get(0) I access the first one and nodes.get(0).xpath("//x/text()").get(0) is equal to "1".
I expect with nodes.get(1) I can access the second element from the nodes list. Furthermore, I expect nodes.get(1).xpath("//x/text()").get(0) to be equal to "2" as stated in the assert. But this is not true. nodes.get(1).xpath("//x/text()").get(0) is equal to "1".
I believe this is a bug.
Please, explain how does it refer to the root.

from jcabi-xml.

yegor256 avatar yegor256 commented on June 30, 2024

@piotrkot the XPath location // means "search from the ROOT of the document". Thus, no matter where you are at the moment, it will find you everything that exists in the entire document. This is a feature, not a bug :)

from jcabi-xml.

piotrkot avatar piotrkot commented on June 30, 2024

@yegor256 Now I understand. Replacing xpath("//x/text()") with xpath("x/text()") solves my problem.
Thank you (and good to have you back with short response times :) )

from jcabi-xml.

yegor256 avatar yegor256 commented on June 30, 2024

@piotrkot wring.io helps me a lot :)

from jcabi-xml.

piotrkot avatar piotrkot commented on June 30, 2024

@yegor256 Yes, I know. I read you blog regularly :) But this issue was opened for 5 months ;)

from jcabi-xml.

yegor256 avatar yegor256 commented on June 30, 2024

@piotrkot now I'm almost live on GitHub)

from jcabi-xml.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.