title: parsing xml in javascript
body: <p>I need to create custom objects based on an XML input, the rule is that for every node if it has a direct child node is named <code>EndNode</code> and the text value of which is <code>1</code>, then I create a leaf object. So for every node, I need to check the direct child with name <code>EndNode</code> and its value.  It's not so easy with the DOM API and DOM selector (in this case I use <code>Ext.DomQuery</code>) doesn't have a way to select direct child of the root node...  Below is my attempt for using DOM selector, I need to wrap the node around with another level of the node for the selector to work. But I can't just say new <code>Node()</code>, it silently fails.
  I guess I have to walk through <code>n.childNodes</code>, but it is complicated to do it this way to check the rule I described above. Any solution?</p>
  <pre><code>Ext.each(node.childNodes, function(n){
      if (n.nodeType == this.XML_NODE_ELEMENT) {
          var tmp=new Node();
          console.log('hi');
          tmp.appendChild(n);
          console.log(Ext.DomQuery.select(n.tagName+&quot;&gt;EndNode&quot;, tmp));
      }
  }
  </code></pre>