How to iterate over a node list and get child elements? <p>I have some XML like this:</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;person&gt; &lt;version&gt;1.1&lt;/version&gt; &lt;lname&gt;xxxx&lt;/lname&gt; &lt;fname&gt;yyyy&lt;/fname&gt; &lt;address&gt; &lt;city&gt;zzzz&lt;/city&gt; &lt;state&gt;ffff&lt;/state&gt; &lt;country&gt;aaaa&lt;/country&gt; &lt;address&gt; &lt;dob&gt;xx-xx-xxxx&lt;/dob&gt; &lt;familymembers&gt; &lt;father&gt; &lt;fname&gt;bbbb&lt;/fname&gt; &lt;lname&gt;dddd&lt;/lname&gt; &lt;/father&gt; &lt;mother&gt; &lt;fname&gt;zzzz&lt;/fname&gt; &lt;lname&gt;aaaa&lt;/lname&gt; &lt;/mother&gt; &lt;sibling&gt; &lt;fname&gt;bbbb&lt;/fname&gt; &lt;lname&gt;dddd&lt;/lname&gt; &lt;/sibling&gt; &lt;/familymembers&gt; &lt;/person&gt; </code></pre> <p>My requirement is that all child elements should be traversed and placed inside a map as key-value pairs like this:</p> <pre><code>persion.version --&gt; 1.1 persion.lname --&gt; xxxx persion.fname --&gt; yyyy person.address.city --&gt; zzzz person.address.state --&gt; ffff person.address.country --&gt; aaaa person.familymembers.father.fname --&gt; bbbb person.familymembers.father.lname --&gt; dddd person.familymembers.mother.fname --&gt; zzzz person.familymembers.mother.lname --&gt; aaaa person.familymembers.sibling.fname --&gt; bbbb person.familymembers.sibling.lname --&gt; dddd </code></pre>