0

Need to select all nodes from the path a/b/c as NodeList from a Document using getElementsByTagName() . How do i provide path of node as input?

eg: -

<root>
    <a>
        <b>
            <c>1</c>
            <c>2</c>
            <c>3</c>
            <c>4</c>
            <c>5</c>
            <c>6</c>
        </b>
    </a>
</root>

need to select all 'c' nodes from the path a/b/c . How can I achieve this. Directly selecting c is an option, but to avoid ambiguity if more 'c's are present, I need to give the path. How do I achieve this?

1 Answer 1

4

Take a look at the Java XPathAPI. You probably want to specify an XPath of /root/a/b to specify all the <c/> nodes in the above hierarchy.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.