1

My XML looks like the below one. I want to check the value of 'number' when //book//genre/text()='classic' , i want to return both 1000 and 1003. Can anybody help please?

<list>
<book>
    <author>
        <name>John</name>
        <number>1000</number>
    </author>
    <otherDetails>
        <genre>classic</genre>
        <price>$50</price>
    </otherDetails>
    <title>Dusk</title>
    <isbn>dsdaassda</isbn>
</book>
<book>
    <author>
        <name>MARK</name>
        <number>1001</number>
    </author>
    <otherDetails>
        <genre>comedy</genre>
        <price>$140</price>
    </otherDetails>
    <title>Midnight</title>
    <isbn>dsdaassda</isbn>
</book>
<book>
    <author>
        <name>Pete</name>
        <number>1003</number>
    </author>
    <otherDetails>
        <genre>classic</genre>
        <price>$140</price>
    </otherDetails>
    <title>Morning</title>
    <isbn>EFGH</isbn>
</book>

1 Answer 1

4

/list/book[otherDetails/genre='classic']/author/number

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

1 Comment

@vpk it does. Be aware that node and attribute names and values are case-sensitive

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.