0

I have XML structure like below. XML is very large I am just showing related part.

<data>
    <book>
        <name xml:lang='Eng'>someValue</name>
    </book>
</data>

I have to find out attribute value using node value. I have values of all book names in array. So I have value someValue using it I have to find out value of attribute xml:lang. Expected output is Eng in this case. I searched for answer but all are for reverse case that is get node value using attribute value

1 Answer 1

1

Try the following XPath

//data/book/name[text()='someValue']/@xml:lang"

The xml: namespace is included in the XML spec and so doesn't need to be defined separately.

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.