I am new to XPath and would like to know how to extract values in an XML document.
I have an XML:
<root>
<element1 attrib1 = value1 attrib2 = value2 >
<element2 attrib1 = value1 attrib2 = value2 >
<element3 attrib1 = value1 attrib2 = value2 >
</root>
What I want to do is extract all attrib=value pairs alongwith the element name.
Eg:
element1 attrib1 value1
element2 attrib2 value2
.
.
element3 attrib2 value2
I have tried using the '//@*' XPath query, which return attrib=value, not the elt name.
Any ideas?
Thanks!
You can use
'*/*'to find all elements at the 2nd level.