title: parsing a DOMNodeList in PHP
body: <p>A web service return Xml of format </p>
  
  <pre><code>&lt;string&gt;
    &lt;NewDataSet&gt;
      &lt;DealBlotter&gt;
        &lt;CustomerReference&gt;161403239&lt;/CustomerReference&gt;
        &lt;Symbol&gt;EUR/USD&lt;/Symbol&gt;
        &lt;BuySell&gt;S&lt;/BuySell&gt;
        &lt;ContractValue&gt;-100000&lt;/ContractValue&gt;
        &lt;Price&gt;1.35070&lt;/Price&gt;
        &lt;CounterValue&gt;-135070&lt;/CounterValue&gt;
        &lt;TradeDate&gt;2011-01-20 22:05:21.690&lt;/TradeDate&gt;
        &lt;ConfirmationNumber&gt;78967117&lt;/ConfirmationNumber&gt;
        &lt;Status&gt;C&lt;/Status&gt;
        &lt;lTID&gt;111913820&lt;/lTID&gt;
      &lt;/DealBlotter&gt;
    &lt;/NewDataSet&gt;
  &lt;/string&gt;
  </code></pre>
  
  <p>Now i am using curl to access this and then -</p>
  
  <pre><code>$xml = simplexml_load_string($result);
  $dom = new DOMDOcument();
  
  // Load your XML as a string
  $dom-&gt;loadXML($xml);
  
  // Create new XPath object
  $xpath = new DOMXpath($dom);
  
  $res = $xpath-&gt;query("/NewDataSet/DealBlotter");
  
  foreach($res as $node)
  {
      print "i went inside foreach";
      $custref =  ($node-&gt;getElementsByTagName("CustomerReference")-&gt;item(0)-&gt;nodeValue);
      print $custref;
      $ccy = ($node-&gt;getElementsByTagName("Symbol")-&gt;item(0)-&gt;nodeValue);
      print $ccy;
      $type = ($node-&gt;getElementsByTagName("BuySell")-&gt;item(0)-&gt;nodeValue);
      $lots = ($node-&gt;getElementsByTagName("ContractValue")-&gt;item(0)-&gt;nodeValue);
      $price = ($node-&gt;getElementsByTagName("Price")-&gt;item(0)-&gt;nodeValue);
      $confnumber = ($node-&gt;getElementsByTagName("ConfirmationNumber")-&gt;item(0)-&gt;nodeValue);
      $status = ($node-&gt;getElementsByTagName("Status")-&gt;item(0)-&gt;nodeValue);
      $ltid = ($node-&gt;getElementsByTagName("lTID")-&gt;item(0)-&gt;nodeValue);
      $time = ($node-&gt;getElementsByTagName("TradeDate")-&gt;item(0)-&gt;nodeValue);
  
  }
  </code></pre>
  
  <p><strong>But nothing is getting printed.</strong> except the dummy statement.
  using <code>$res = $xpath-&gt;query("/string/NewDataSet/DealBlotter");</code> did not help. Also a <code>print_r($res);</code> gives output as <code>DOMNodeList obect.</code></p>
  
  <p>Doing this also does not print anything</p>
  
  <pre><code>$objDOM = new DOMDocument(); 
  $objDOM-&gt;load($result);
  $note = $objDOM-&gt;getElementsByTagName("DealBlotter");
  foreach( $note as $value )
  {       
      print "hello";  
      $tasks = $value-&gt;getElementsByTagName("Symbol");
      $task  = (string)$tasks-&gt;item(0)-&gt;nodeValue;
  
      $details = $value-&gt;getElementsByTagName("Status");
      $detail  = (string)$details-&gt;item(0)-&gt;nodeValue;
  
      print "$task :: $detail &lt;br&gt;"; 
  }
  </code></pre>