title: How to access tagName of custom node in DOM
body: <p>I am reading a custom xml-file with custom tags such as <code>&lt;section&gt;&lt;/section&gt;</code> into a variable <code>text</code>. I then apply the following few lines of <em>plain javascript</em>:</p>
  <pre><code>parser = new DOMParser();
  xmlDoc = parser.parseFromString(text, 'text/xml');
  console.log(xmlDoc.documentElement);
  parseDOM(xmlDoc.documentElement);
  </code></pre>
  <p>where</p>
  <pre><code>function parseDOM(node){
      type = node.nodeName;
      console.log(type);
      for(child in node.children){
          parseDOM(child);
      }
  }
  </code></pre>
  <p>The <code>console.log(xmlDoc.documentElement)</code> part prints out the complete hierarchy without any problems, in particular with the tags having the correct names. Unfortunately the <code>console.log(type)</code> part prints out &quot;undefined&quot; for all my custom tags.</p>
  <blockquote>
  <p>How can I test, whether the node at hand is of the custom type <code>&lt;section&gt;&lt;/section&gt;</code>? I was expecting <code>node.nodeName == 'section'</code> to work, but apparently it does not... And while we are at it, how can I test, whether the current node is a text-block?</p>
  </blockquote>
  <p>Thank you very much for your support.</p>
  <p>My goal is to replace the tags (e.g. turn <code>&lt;section&gt;</code> into <code>&lt;h2&gt;</code>), but also might do some heavier alterations to some tags in the future. I know that there very likely is some library perfectly suited for the job, but I am using this project to finally to get back writing some code, so I would prefer if the solution remains within standard javascript. Again, thank you very much for your help.</p>