title: How to deal with nested XML structure in JavaScript?
body: <p>I have the following nested XML structure</p>
  
  <pre><code>&lt;forum&gt;
     &lt;title&gt;Title1&lt;/title&gt;
     &lt;id&gt;123&lt;/id&gt;
     &lt;forum&gt;
         &lt;title&gt;Title1b&lt;/title&gt;
         &lt;id&gt;123b&lt;/id&gt;
     &lt;/forum&gt;
  &lt;/forum&gt;
  &lt;forum&gt;
     &lt;title&gt;Title2&lt;/title&gt;
     &lt;id&gt;321&lt;/id&gt;
  &lt;/forum&gt;
  &lt;forum&gt;
     &lt;title&gt;Title3&lt;/title&gt;
     &lt;id&gt;456&lt;/id&gt;
  &lt;/forum&gt;
  </code></pre>
  
  <p>As you can see in the above structure, I have a nested "forum" tag in the first element but not in the second and third.  I have tried running a if <code>getElementsByTagName("forum").item(0).text</code> on the parent nodes, but it throws an error for the second and third parent nodes because the child node for "forum" doesn't actually exist.</p>
  
  <p>How could I properly check to see if those child nodes exist and then act on them?</p>
  
  <p>Thanks!!!</p>