title: Parsing XML to js data, how to acces specific tag?
body: <h2>Situation</h2>
  
  <p>For a database analysis tool I need to parse a bunch of generated XML files (hibernate reverse engineered XML files) to javascript for visualization purposes. As I am very new to javascript being a java developer, I am trying to take small steps at a time. Eventually I want to parse the xml files to d3.js force layout graph, but thats a bridge to far for me for now.</p>
  
  <h2>Reproduce</h2>
  
  <p>Given the following html file:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;meta charset="utf-8"&gt;
  &lt;script src="//d3js.org/d3.v3.min.js"&gt;&lt;/script&gt;
  &lt;script src=d3-queue.js&gt;&lt;/script&gt;
  &lt;script&gt;
  
  var q = d3_queue.queue();
  
  // TODO 1: for each xml in folder xyz ... defer(d3.xml, "dynamicvalue", "application/xml") instead of hard coded
      .defer(d3.xml, "Actor.hbm.xml", "application/xml")
      .defer(d3.xml, "Film.hbm.xml", "application/xml")
      .defer(d3.xml, "Category.hbm.xml", "application/xml")
      .await(analyze);   
  
  // obviously the function parameter need to be dynamic and not hard coded actor, film, category...
  function analyze(error, actor,film,category) {
  // TODO 2: for each read xml do ...
  
    if (error) throw error;
    console.log(category)
    console.log("XML Root Tag Name: " + category.documentElement.tagName)
    console.log("Checking Child Nodes: " + category.documentElement.childNodes[0].hasChildNodes)
    console.log("First Child: " + category.documentElement.childNodes[1].firstChild.tagName)
    console.log("Node Value: " + category.documentElement.childNodes[0].attributes.getNamedItem("id").nodeValue)      
  
  }
  &lt;/script&gt;
  </code></pre>
  
  <p>And given the following example .xml file</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
  "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"&gt;
  &lt;!-- Generated 15-mrt-2016 20:29:28 by Hibernate Tools 3.2.2.GA --&gt;
  &lt;hibernate-mapping&gt;
      &lt;class name="nl.sander.mieras.localhost.sakila.Category" table="category" catalog="sakila"&gt;
          &lt;id name="categoryId" type="java.lang.Byte"&gt;
              &lt;column name="category_id" /&gt;
              &lt;generator class="identity" /&gt;
          &lt;/id&gt;
          &lt;property name="name" type="string"&gt;
              &lt;column name="name" length="25" not-null="true" /&gt;
          &lt;/property&gt;
          &lt;property name="lastUpdate" type="timestamp"&gt;
              &lt;column name="last_update" length="0" not-null="true" /&gt;
          &lt;/property&gt;
          &lt;set name="filmCategories" inverse="true"&gt;
              &lt;key&gt;
                  &lt;column name="category_id" not-null="true" /&gt;
              &lt;/key&gt;
              &lt;one-to-many class="nl.sander.mieras.localhost.sakila.FilmCategory" /&gt;
          &lt;/set&gt;
      &lt;/class&gt;
  &lt;/hibernate-mapping&gt;
  </code></pre>
  
  <h2>Question</h2>
  
  <p>How do I dynamically <em>read the value</em> from the table name (here it is: "category") and save it to var nodes?</p>
  
  <p>I have been stuck on parsing the xml to the correct js data for quite a while now, so any push in the right direction would be amazing.</p>
  
  <h2>Research</h2>
  
  <p>I have tried the examples from <a href="http://www.hiteshagrawal.com/javascript/javascript-parsing-xml-in-javascript/" rel="nofollow noreferrer">http://www.hiteshagrawal.com/javascript/javascript-parsing-xml-in-javascript/</a> but I am not getting expected results. Those expected results would be for the child node something like <code>&lt;id name="categoryId" type="java.lang.Byte"&gt;</code>. </p>
  
  <p>Also I tried extensively to get things working based answer given by @Lars Grammel on the question <a href="https://stackoverflow.com/questions/10682856/how-to-import-xml-data-using-d3-js">How to import XML data using d3.js?</a> . Even though the links and answer is great, I can't make it work for my situation (not enough knowhow)</p>
  
  <p>The first "end" goal is to create a force layout with all the table names as nodes (with no links yet, links will eventually be the one-to-many and the many-to-one mappings), as shown in <a href="https://bl.ocks.org/mbostock/1080941" rel="nofollow noreferrer">https://bl.ocks.org/mbostock/1080941</a></p>