How can I return all the 'make' items from the xml document using an xpath query
<vehicles>
<car>
<make>Benz</make>
<make>Nissan</make>
</car>
<motorbike>
<make>Honda</make>
</motorbike>
How can I return all the 'make' items from the xml document using an xpath query
<vehicles>
<car>
<make>Benz</make>
<make>Nissan</make>
</car>
<motorbike>
<make>Honda</make>
</motorbike>
I would use /*/*/make
. (You could use //make
, but I try to avoid //
for efficiency reasons.)
The w3schools has a good tutorial on XPath: http://www.w3schools.com/xpath/default.asp
Also, you should add </vehicles>
to your XML to make it well formed.