title: Parse XML namespaces with php SimpleXML
body: <p>I know this has been asked many many times but I haven't been able to get any of the suggestions to work with my situation and I have searched the web and here and tried everything and anything and nothing works. I just need to parse this XML with the namespace cap: and just need four entries from it. </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;entry&gt;
      &lt;id&gt;http://alerts.weather.gov/cap/wwacapget.php?x=TX124EFFB832F0.SpecialWeatherStatement.124EFFB84164TX.LUBSPSLUB.ac20a1425c958f66dc159baea2f9e672&lt;/id&gt;
      &lt;updated&gt;2013-05-06T20:08:00-05:00&lt;/updated&gt;
      &lt;published&gt;2013-05-06T20:08:00-05:00&lt;/published&gt;
      &lt;author&gt;
          &lt;name&gt;w-nws.webmaster@noaa.gov&lt;/name&gt;
      &lt;/author&gt;
      &lt;title&gt;Special Weather Statement issued May 06 at 8:08PM CDT by NWS&lt;/title&gt;
      &lt;link href="http://alerts.weather.gov/cap/wwacapget.php?x=TX124EFFB832F0.SpecialWeatherStatement.124EFFB84164TX.LUBSPSLUB.ac20a1425c958f66dc159baea2f9e672"/&gt;
      &lt;summary&gt;...SIGNIFICANT WEATHER ADVISORY FOR COCHRAN AND BAILEY COUNTIES... AT 808 PM CDT...NATIONAL WEATHER SERVICE DOPPLER RADAR INDICATED A STRONG THUNDERSTORM 30 MILES NORTHWEST OF MORTON...MOVING SOUTHEAST AT 25 MPH. NICKEL SIZE HAIL...WINDS SPEEDS UP TO 40 MPH...CONTINUOUS CLOUD TO GROUND LIGHTNING...AND BRIEF MODERATE DOWNPOURS ARE POSSIBLE WITH&lt;/summary&gt;
      &lt;cap:event&gt;Special Weather Statement&lt;/cap:event&gt;
      &lt;cap:effective&gt;2013-05-06T20:08:00-05:00&lt;/cap:effective&gt;
      &lt;cap:expires&gt;2013-05-06T20:45:00-05:00&lt;/cap:expires&gt;
      &lt;cap:status&gt;Actual&lt;/cap:status&gt;
      &lt;cap:msgType&gt;Alert&lt;/cap:msgType&gt;
      &lt;cap:category&gt;Met&lt;/cap:category&gt;
  
      &lt;cap:urgency&gt;Expected&lt;/cap:urgency&gt;
      &lt;cap:severity&gt;Minor&lt;/cap:severity&gt;
      &lt;cap:certainty&gt;Observed&lt;/cap:certainty&gt;
      &lt;cap:areaDesc&gt;Bailey; Cochran&lt;/cap:areaDesc&gt;
      &lt;cap:polygon&gt;34.19,-103.04 34.19,-103.03 33.98,-102.61 33.71,-102.61 33.63,-102.75 33.64,-103.05 34.19,-103.04&lt;/cap:polygon&gt;
      &lt;cap:geocode&gt;
          &lt;valueName&gt;FIPS6&lt;/valueName&gt;
          &lt;value&gt;048017 048079&lt;/value&gt;
          &lt;valueName&gt;UGC&lt;/valueName&gt;
  
          &lt;value&gt;TXZ027 TXZ033&lt;/value&gt;
      &lt;/cap:geocode&gt;
      &lt;cap:parameter&gt;
          &lt;valueName&gt;VTEC&lt;/valueName&gt;
          &lt;value&gt;
          &lt;/value&gt;
      &lt;/cap:parameter&gt;
  &lt;/entry&gt;
  </code></pre>
  
  <p>I am using simpleXML and I have a small simple test script set up and it works great for parsing regular elements. I can't for the dickens of me find or get a way to parse the elements with the namespaces. </p>
  
  <p>Here is a small sample test script with code I am using and works great for parsing simple elements. How do I use this to parse namespaces? Everything I've tried doesn't work. I need it to be able to create variables so I can be able to embed them in HTML for style. </p>
  
  <pre><code>&lt;?php 
  
  $html = "";  
  
  // Get the XML Feed
  $data = "http://alerts.weather.gov/cap/tx.php?x=1";
  
  
  // load the xml into the object
  $xml = simplexml_load_file($data);
  
  for ($i = 0; $i &lt; 10; $i++){
      $title = $xml-&gt;entry[$i]-&gt;title;
      $summary = $xml-&gt;entry[$i]-&gt;summary;
  
      $html .= "&lt;p&gt;&lt;strong&gt;$title&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;$summary&lt;/p&gt;&lt;hr/&gt;";
  
  }
  
   echo $html; 
  ?&gt; 
  </code></pre>
  
  <p>This works fine for parsing regular elements but what about the ones with the cap: namespace under the entry parent?</p>
  
  <pre><code>&lt;?php
  ini_set('display_errors','1');
  
  $html = "";
  $data = "http://alerts.weather.gov/cap/tx.php?x=1";
  $entries = simplexml_load_file($data);
  if(count($entries)):
      //Registering NameSpace
      $entries-&gt;registerXPathNamespace('prefix', 'http://www.w3.org/2005/Atom');
      $result = $entries-&gt;xpath("//prefix:entry");
      //echo count($asin);
      //echo "&lt;pre&gt;";print_r($asin);
      foreach ($result as $entry):
          $title = $entry-&gt;title;
          $summary = $entry-&gt;summary;
  
          $html .= "&lt;p&gt;&lt;strong&gt;$title&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;$summary&lt;/p&gt;$event&lt;hr/&gt;";
  
      endforeach;
  endif;
  
  echo $html;
  
  ?&gt;
  </code></pre>
  
  <p>Any help would be greatly appreciated.</p>
  
  <p>-Thanks</p>