title: Problem with 'undefined namespace prefix' with XPath in PHP?
body: <p>Very new to PHP/programming in general, and I've been trying to run a PHP file set up to parse an Atom feed outputted from the Google Search API for Shopping. When run however, the code outputs a large number enter code heref errors (warnings), all having to do with XPath:</p>
  
  <pre><code>Warning: SimpleXMLElement::xpath() [simplexmlelement.xpath]: Undefined namespace prefix in /home/ultradea/public_html/gtest/search.php on line 205
  
  Warning: SimpleXMLElement::xpath() [simplexmlelement.xpath]: xmlXPathEval: evaluation failed in /home/ultradea/public_html/gtest/search.php on line 205
  
  Warning: Invalid argument supplied for foreach() in /home6/legionit/public_html/pricemash/search.php on line 289
  </code></pre>
  
  <p>The full code I'm working with can be found here: <a href="http://www.google.com/codesearch/p?hl=en#welp0towd2Y/trunk/src/php/search.php&amp;q=package%3ahttp://gcs-admin-toolkit%5C.googlecode%5C.com&amp;sa=N&amp;cd=3&amp;ct=rc" rel="nofollow">search.php</a></p>
  
  <p>Here's the uploaded copy I'm working with that outputs the errors - <a href="http://ultra-deals.com/gtest/search.php" rel="nofollow">http://ultra-deals.com/gtest/search.php</a></p>
  
  <p>And here's the specific code in question</p>
  
  <pre><code>Lines 204-207
  $xml = simplexml_load_string($return);
  $result = $xml-&gt;xpath('//openSearch:totalResults');
  $START = array_shift($xml-&gt;xpath('openSearch:startIndex'));
  $RESULTS = array_shift($xml-&gt;xpath('openSearch:totalResults'));
  &lt;...&gt; Line 261
  $spelling_suggestion = array_shift($xml-&gt;xpath('s:spelling/s:suggestion'));
  &lt;...&gt; Lines 273-280
  $promos = "";
  foreach ($xml-&gt;xpath('s:promotions/*') as $item) {
     $promos .= "&lt;td&gt;&lt;a href='$item[link]'&gt;$item[description]";
     if ($item[imageLink] != "") {
       $promos .= "&lt;br/&gt;&lt;img src='$item[imageLink]'&gt;";
     }
     $promos .= "&lt;/td&gt;";
  }
  &lt;...&gt; Lines 328-335
  $NARROW = "";
  foreach ($xml-&gt;xpath('s:facets/*') as $item) {
   $values = $item-&gt;xpath('s:bucket');
   $type = $item['type'];
   $attrib_name = $item['name'];
   if ($attrib_name == "") {
     $attrib_name = $item['property'];  // Default types
   }
  </code></pre>
  
  <p>Each of those correspond to one or more of the error messages outputted on the search.php file I uploaded to my server. I have no experience with XPath, so I'm not even exactly sure what the namespace prefix in question is. Really appreciate the help! </p>