title: get elements by name from a DOMNodeList
body: <p>In the following code, I retrieve with DOM a list of nodes from an xml document. Then I would like to select, by their tag name, some of these nodes.</p>
  <pre><code>$index = new DOMDocument();
  $index-&gt;load('index.xml');
  $xpath = new DOMXpath($index);
  $related_notions = $xpath-&gt;query(&quot;/index/notion[name='&quot; . $name . &quot;']/relations/*&quot;); // the variable $name is dynamically defined previously in the script
  foreach ($related_notions-&gt;getElementsByTagName(&quot;superordinate&quot;) as $item) {
  
  // do something
  
  }
  </code></pre>
  <p>I get the following error: <code>Uncaught Error: Call to undefined method DOMNodeList::getElementsByTagName()</code></p>
  <p>I don't understand why the method <code>getElementsByTagName()</code> is not defined for <code>DOMNodeList</code>. After all, getting elements by their name seems to me something obvious that one might want to do with a node list. At any rate, my actual question is: How can I do what I want to do? That is, in the absence of the method <code>getElementsByTagName()</code>, how do I get elements by tag name from a node list?</p>
  <p>Thanks in advance for your help!</p>