title: Using XML Parser to get recent youtube videos from a user
body: <p>Yo!</p>
  
  <p>So, my goal is to get the three most recent videos uploaded by a youtube user, in this case "aosjeff". I understand that I can send a "get" request to youtube and then parse that xml document using the XML parser (I cannot use php, the site-building site I'm using won't let me), and I'm attempting to use some code here to store the results of the "get" request in a string in javascript so that I can parse them. But whenever I run this code and call "alert(txt)", only the string "[object document]" is returned, and not the xml data. Here's the code:</p>
  
  <pre><code>function getVideoHTML()
  {
      if (window.XMLHttpRequest)
      {// code for IE7+, Firefox, Chrome, Opera, Safari
        xmlhttp=new XMLHttpRequest();
      }
      else
      {// code for IE6, IE5
        xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
      xmlhttp.open("GET","https://gdata.youtube.com/feeds/api/users/aosjeff/uploads",false);
      xmlhttp.send();
  
      txt = xmlhttp.responseXML;
  
      if (window.DOMParser)
      {
          parser=new DOMParser();
          xmlDoc=parser.parseFromString(txt,"text/xml");
      }
      else // Internet Explorer
      {
          xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
          xmlDoc.async=false;
          xmlDoc.loadXML(txt);
      }
  
      //document.getElementById("to").innerHTML=
      //xmlDoc.getElementsByTagName("to")[0].childNodes[0].nodeValue;
      //document.getElementById("from").innerHTML=
      //xmlDoc.getElementsByTagName("from")[0].childNodes[0].nodeValue;
      //document.getElementById("message").innerHTML=
      //xmlDoc.getElementsByTagName("body")[0].childNodes[0].nodeValue;
      alert(txt);
  }
  </code></pre>
  
  <p>That's one problem. The other, I guess, is how to use the parser--which I've read about but still don't understand. Can you all explain how it works? I understand that I search for a certain tag--and that then it gives me a list of the elements in that tag. But how do I navigate that list?</p>
  
  <p>Cheers, thanks for your time</p>
  
  <p>Simon</p>