jquery parse xml with unlimited child level category <p>I'm fairly new on parsing xml with jquery, so if my question looks like noobish, please forgive me.</p> <p>I have an xml it contains my recursive categories. Some of them has sub categories, some of them not. It has some deep level categories under sub categories.</p> <p>Sample of xml; </p> <pre><code>&lt;Urunler&gt; &lt;Urun&gt; &lt;ID&gt;1&lt;/ID&gt; &lt;Parent&gt;0&lt;/Parent&gt; &lt;Name&gt;Red&lt;/Name&gt; &lt;/Urun&gt; &lt;Urun&gt; &lt;ID&gt;2&lt;/ID&gt; &lt;Parent&gt;0&lt;/Parent&gt; &lt;Name&gt;Green&lt;/Name&gt; &lt;/Urun&gt; &lt;Urun&gt; &lt;ID&gt;3&lt;/ID&gt; &lt;Parent&gt;0&lt;/Parent&gt; &lt;Name&gt;Blue&lt;/Name&gt; &lt;/Urun&gt; &lt;Urun&gt; &lt;ID&gt;4&lt;/ID&gt; &lt;Parent&gt;3&lt;/Parent&gt; &lt;Name&gt;Sky&lt;/Name&gt; &lt;/Urun&gt; &lt;Urun&gt; &lt;ID&gt;5&lt;/ID&gt; &lt;Parent&gt;3&lt;/Parent&gt; &lt;Name&gt;Sea&lt;/Name&gt; &lt;/Urun&gt; &lt;Urun&gt; &lt;ID&gt;6&lt;/ID&gt; &lt;Parent&gt;5&lt;/Parent&gt; &lt;Name&gt;Fish&lt;/Name&gt; &lt;/Urun&gt; &lt;Urun&gt; &lt;ID&gt;7&lt;/ID&gt; &lt;Parent&gt;4&lt;/Parent&gt; &lt;Name&gt;Bird&lt;/Name&gt; &lt;/Urun&gt; &lt;/Urunler&gt; </code></pre> <p>Desired HTML output</p> <pre><code>&lt;ul&gt; &lt;li&gt;Red&lt;/li&gt; &lt;li&gt;Green&lt;/li&gt; &lt;li&gt;Blue &lt;ul&gt; &lt;li&gt;Sky &lt;ul&gt; &lt;li&gt;Bird&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;li&gt;Sea &lt;ul&gt; &lt;li&gt;Fish&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;/ul&gt; </code></pre> <p>I find an example on <a href="http://codereview.stackexchange.com/questions/43449/parsing-xml-data-to-be-put-onto-a-site-with-jquery">http://codereview.stackexchange.com/questions/43449/parsing-xml-data-to-be-put-onto-a-site-with-jquery</a> unfortunately it supports only first child level.</p> <p>if needed; i call my xml via <code>$.ajax</code></p> <pre><code>$.ajax({ url: 'webservice/Resim/Kategori.xml', dataType: 'xml', cache:true, success: parseXml }); </code></pre> <p>Any help will greatly appricated.</p>