Any particular reason you're doing this in JS? Does the XML result from an AJAX query?I am using Javascript to read the XML and then Build the <A> tag for all children of the main node.
var menu = document.getElementById('Menu');
var link = document.createElement('a');
link.href=xmlMenu.getElementsByTagName("link")[0].firstChild.nodeValue;
var title = xmlMenu.getElementsByTagName("title")[0].firstChild.nodeValue;
link.appendChild(document.createTextNode(title));
menu.appendChild(link);
, [PHP] or [HTML] tags as appropriate. It makes the code readable.