Iris
Iris

Reputation: 1341

Xpath to get a child node value

How can I get the values of all nodes called "title" from the XML below ?

<bookstore>
<bookA>
 <title> Title Book A</title>
 <desc> Book A </desc>
<bookA>

<bookB>
 <title> Title Book B</title>
 <desc> Book B </desc>
<bookB>
</bookstore>

Thanks

Upvotes: 1

Views: 4493

Answers (2)

Trevor Tubbs
Trevor Tubbs

Reputation: 2117

Another option would be:

bookstore/*/title

Upvotes: 1

user186118
user186118

Reputation:

Try: bookstore//title

// means any child (including grandchildren) named title

By the way, you didn't close off the book elements.

Upvotes: 4

Related Questions