repalviglator Posted March 3, 2007 Share Posted March 3, 2007 Can someone tell me why this code doesn't output anything? Is there something extra I need to do? I'm expecting to get the list of places stored in $nodeList. <?php error_reporting(E_STRICT); $doc = new DOMDocument; $doc->load("http://www.43places.com/service/search_places?api_key=1234&q=Ann+Arbor"); $xpath = new DOMXPath($doc); $nodeList = $xpath->query("//feed/place"); foreach($nodeList as $node){ var_dump($node); } ?> Link to comment https://forums.phpfreaks.com/topic/40985-xpath-with-php-5/ Share on other sites More sharing options...
Tyche Posted March 3, 2007 Share Posted March 3, 2007 I'm not sure why your code isn't working The following code however will extract the "name" values from within each "place" node <?php error_reporting(E_STRICT); $doc = new DOMDocument; $doc->load("http://www.43places.com/service/search_places?api_key=1234&q=Ann+Arbor"); $nodeList = $doc->getElementsByTagName('name'); foreach($nodeList as $node){ echo "$node->nodeValue\n"; } ?> Link to comment https://forums.phpfreaks.com/topic/40985-xpath-with-php-5/#findComment-198452 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.