I have this XML:
<root>
<items>
<item1>
<tag1>1</tag1>
<sub>
<sub1>10 </sub1>
<sub2>20 </sub2>
</sub>
</item1>
<item2>
<tag1>1</tag1>
<sub>
<sub1> </sub1>
<sub2> </sub2>
</sub>
</item2>
</items>
</root>
I want to get the item1 element and the name and values of the child elements.
That is, i want to get: tag1 – 1,sub1-10,sub2-20.
How can i do this? so far i can only get elements without children.
I get this output loading the xml of your question in file named: myxml.xml:
…a bit wordy, but allow us to understand how it works. PS: I found a good guide in here