title: Converting nested xml to nested html recursively
body: <p>I want to convert nested xml to nested ul li structure. I have written all the code but there is a error in it. I have spent whole day but can't getting it to work. The error can be very simple. Can anyone please look into that and reply to me.</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
      &lt;script type="text/javascript"&gt;
          var str = ""; var temp = "";
          function makeTree() {
              treeUL = createNestedTree($('root'));
              $("#tree").append(treeUL);
          }
  
          function createNestedTree(obj) {
              if($(obj).children().size() != 0) {
                  str = str + "&lt;li&gt;" + $(obj).attr("name") + "&lt;/li&gt;&lt;ul&gt;";
                  $(obj).children("item").each(function() {
                      returnValue = createNestedTree($(this));
                      str = str + returnValue;
                  });
  
                  return str + "&lt;/ul&gt;";
              }
              else {
                  temp = "&lt;li&gt;" + $(obj).attr("name") + "&lt;/li&gt;&lt;ul&gt;&lt;/ul&gt;";
                  return temp;
              }
          }
      &lt;/script&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
      &lt;!-- xml structure start --&gt;
      &lt;root&gt;
          &lt;item name="a"&gt;
              &lt;item name="d"&gt;
                  &lt;item name="d"&gt;&lt;/item&gt;
                  &lt;item name="e"&gt;&lt;/item&gt;     
                  &lt;item name="f"&gt;&lt;/item&gt;
              &lt;/item&gt;
              &lt;item name="g"&gt;&lt;/item&gt;
              &lt;item name="h"&gt;&lt;/item&gt;
          &lt;/item&gt;
          &lt;item name="b"&gt;&lt;/item&gt;
          &lt;item name="c"&gt;&lt;/item&gt;
      &lt;/root&gt;
      &lt;!-- xml structure end --&gt;
  
      &lt;a href="javascript:makeTree()"&gt;Make Tree&lt;/a&gt;
      &lt;div id="tree"&gt;&lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;​
  </code></pre>
  
  <p>Fiddle is <a href="http://jsfiddle.net/ashwyn/b2eMe/28/" rel="nofollow">here</a></p>
  
  <p>I have created xml inside html because I do not know how to refer external xml into fiddle. But it behaves exactly like xml when passed to the function so no issues about that.</p>