title: XML - Getting the element child value from the attribute using php
body: <p>I'm using php to parse my xml file, all I want to be able to do is to get the element child value from the attribute:</p>
  
  <pre><code>  &lt;question number="1"&gt;
      &lt;type&gt;Main&lt;/type&gt;
    &lt;/question&gt;
  
    &lt;question number="2"&gt;
      &lt;type&gt;Secondary&lt;/type&gt;
    &lt;/question&gt;
  </code></pre>
  
  <p>Pseudo Code (doesn't work):</p>
  
  <pre><code>$xmlDoc = new DOMDocument(); 
  $xmlDoc-&gt;load('questions.xml'); 
  
  $searchNode = $xmlDoc-&gt;getElementsByAttribute("number"); 
  
  foreach( $searchNode as $searchNode ) {
  if ($searchnode == "1"){
  
  $xmlType = $searchNode-&gt;getElementsByTagName( "Type" );
  $valueType = $xmlType-&gt;item(0)-&gt;nodeValue;  
   echo $valueType; 
  
  }else{
  //Do nothing
  }
  
  }
  </code></pre>