title: Parse XML with Namespace using SimpleXML
body: <p>I have this as xml:</p>
  
  <pre><code>&lt;root xmlns:event="http://www.webex.com/schemas/2002/06/service/event"&gt;
      &lt;event:event&gt;
          &lt;event:sessionKey&gt;&lt;/event:sessionKey&gt;
          &lt;event:sessionName&gt;Learn QB in Minutes&lt;/event:sessionName&gt;
          &lt;event:sessionType&gt;9&lt;/event:sessionType&gt;
          &lt;event:hostWebExID&gt;&lt;/event:hostWebExID&gt;
          &lt;event:startDate&gt;02/12/2009&lt;/event:startDate&gt;
          &lt;event:endDate&gt;02/12/2009&lt;/event:endDate&gt;
          &lt;event:timeZoneID&gt;11&lt;/event:timeZoneID&gt;
          &lt;event:duration&gt;30&lt;/event:duration&gt;
          &lt;event:description&gt;&lt;/event:description&gt;
          &lt;event:status&gt;NOT_INPROGRESS&lt;/event:status&gt;
          &lt;event:panelists&gt;&lt;/event:panelists&gt;
          &lt;event:listStatus&gt;PUBLIC&lt;/event:listStatus&gt;
      &lt;/event:event&gt;
      ...
  &lt;/root&gt;
  </code></pre>
  
  <p>How can I loop through all of the event:event nodes and display, for example, all of the event:SessionKey's? </p>
  
  <p>This does not work:</p>
  
  <pre><code>$xml = new SimpleXMLElement($r);
  $xml-&gt;registerXPathNamespace('e', 'http://www.webex.com/schemas/2002/06/service/event');
  
  foreach($xml-&gt;xpath('//e:event') as $event) {
   var_export($event-&gt;xpath('//e:sessionKey'));
  }
  </code></pre>