title: How to get url/href from XML table cell
body: <p>I am having difficulties getting the url/href from an XML cell.</p>
  
  <p>In the example below I am able to get the values of <strong>type</strong> and <strong>subtype</strong> but I don't know how to get the <strong>url</strong> from <strong>photo</strong>.</p>
  
  <p>My thought was that it could work similar to this <strong><em>"var x = elem.getElementsByTagName("photo").url;"</em></strong> but it seems I can't figure it out.</p>
  
  <p>XML:</p>
  
  <pre><code>&lt;item&gt;
      &lt;type&gt;animal&lt;/type&gt;
      &lt;subtype&gt;dog&lt;/contentId&gt;
      &lt;photo url="https://cdn.pixabay.com/photo/2016/02/19/15/46/dog-1210559_1280.jpg"/&gt;
  &lt;/item&gt;
  
  &lt;item&gt;
      &lt;type&gt;animal&lt;/type&gt;
      &lt;subtype&gt;cat&lt;/contentId&gt;
      &lt;photo url="https://cdn.pixabay.com/photo/2017/02/20/18/03/cat-2083492_960_720.jpg"/&gt;
  &lt;/item&gt; 
  </code></pre>
  
  <p>Code:</p>
  
  <pre><code>&lt;style&gt;
  table,
  th,
  td {
    border: 1px solid black;
    border-collapse: collapse;
  }
  th,
  td {
    padding: 5px;
  }
  &lt;/style&gt;
  
  
  &lt;button type="button" onclick="loadDoc()"&gt;Load&lt;/button&gt;
  &lt;br&gt;&lt;br&gt;
  &lt;table id="myTable"&gt;&lt;/table&gt;
  
  
  &lt;script&gt;
  var xmlFile = 'file.xml';
  
  function loadDoc() {
    var xhttp = new XMLHttpRequest();
  
    xhttp.open("GET", xmlFile, true);
    xhttp.send();
    xhttp.onreadystatechange = function() {
      if (this.readyState === 4 &amp;&amp; this.status === 200) {
        xmlFunction(this.response);
      }
    };
  
  }
  
  function xmlFunction(xml) {
    var parser = new DOMParser();
    var xmlDoc = parser.parseFromString(xml, "text/xml");
    var table = "&lt;tr&gt;&lt;th&gt;Type&lt;/th&gt;&lt;th&gt;Subtype&lt;/th&gt;&lt;th&gt;Photo&lt;/th&gt;&lt;/tr&gt;";
    var x = xmlDoc.getElementsByTagName("item");
    for (var elem of x) {
      var type = elem.getElementsByTagName(
    "type")[0].childNodes[0].nodeValue;
      var subtype = elem.getElementsByTagName("subtype")[0].childNodes[0].nodeValue;
      var photo = elem.getElementsByTagName("photo").url;
  
      table += "&lt;tr&gt;&lt;td&gt;" + type + "&lt;/td&gt;&lt;td&gt;" + subtype + "&lt;/td&gt;&lt;td&gt;" + photo + "&lt;/td&gt;&lt;/tr&gt;";
    }
    document.getElementById("myTable").innerHTML = table;
  }
  &lt;/script&gt;
  </code></pre>