XML-Parser Javascript
<p>Let's assume that I have the following XML:</p>

<pre><code>&lt;Level&gt;
&lt;Name&gt;Level1&lt;/Name&gt;
...
&lt;Level&gt;
&lt;Name&gt;Level2&lt;/Name&gt;
...
&lt;Level&gt;
&lt;Name&gt;Level3&lt;/Name&gt;
&lt;Level&gt;
&lt;Name&gt;Sublevel1&lt;/Name&gt;
&lt;Level&gt;
&lt;Name&gt;Sublevel2&lt;/Name&gt;
...
</code></pre>

<p>How can I access the levels and all the sublevels names and put them in a list. I have written the following code:</p>

<pre><code>function getLevel() {
$.get(XmlUrl, function (data) {
var html = "&lt;ol type='i'&gt;";
$(data).find("Level").each(function () {
$(this).children("Level").each(function () {
var list = $(this);
if (list.find("Name")) {
html += "&lt;li&gt;" + $(this).find("Name").text() + "&lt;/li&gt;";
} else {
getLevel();
}
});
});
html += "&lt;/ol&gt;";
$("#div").append(html);
});
}
</code></pre>

<p>All I get is this:</p>

<pre><code>i.Level1
ii.Level2
iii.Level3Sublevel1Sublevel2
iv.Sublevel1
v.Sublevel2
</code></pre>

<p>Does anyone have any ideas?</p>