title: Not recursive (single node level) getElementsByTagName in Python xml.dom
body: <p>Is there any way to use <code>getElementsByTagName</code> only at a single node level and not recursively?</p>
  
  <p>E.g. consider parsing a <code>pom.xml</code> file:</p>
  
  <pre><code>&lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"&gt;
  
      &lt;parent&gt;
          &lt;groupId&gt;com.parent&lt;/groupId&gt;
          &lt;artifactId&gt;parent&lt;/artifactId&gt;
          &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;
          &lt;relativePath&gt;../pom.xml&lt;/relativePath&gt;
      &lt;/parent&gt;
  
      &lt;modelVersion&gt;2.0.0&lt;/modelVersion&gt;
      &lt;groupId&gt;com.parent.somemodule&lt;/groupId&gt;
      &lt;artifactId&gt;some_module&lt;/artifactId&gt;
      &lt;packaging&gt;jar&lt;/packaging&gt;
      &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;
      &lt;name&gt;Some Module&lt;/name&gt;
      ...
  </code></pre>
  
  <p>If I want to get <code>groupId</code> at the top level (specifically <code>project-&gt;groupId</code>, not <code>project-&gt;parent-&gt;groupId</code>), I use:</p>
  
  <pre><code>xmldoc = minidom.parse('pom.xml')
  groupId = xmldoc.getElementsByTagName("groupId")[0].childNodes[0].nodeValue
  </code></pre>
  
  <p>But unfortunately, that finds the first physical occurrence of <code>groupId</code> in the file regardless of the hierarchy level, which is <code>project-&gt;parent-&gt;groupId</code>.  I actually want to do a unrecursive find ONLY at a specific node level, not within its children.  Is there a way to do it in <a href="http://docs.python.org/2/library/xml.dom.html#xml.dom.Document.getElementsByTagName" rel="nofollow noreferrer"><code>xml.dom</code></a>?</p>
  
  <p><strong>UPDATE:</strong>  I switched to <a href="http://www.crummy.com/software/BeautifulSoup/bs4/doc/" rel="nofollow noreferrer"><code>BeautifulSoup</code></a> but still having the same problem with implicit recursive traversing: <a href="https://stackoverflow.com/questions/21147686/finding-a-nonrecursive-dom-subnode-in-python-using-beautifulsoup">Finding a nonrecursive DOM subnode in Python using BeautifulSoup</a></p>