note 60522 modified in function.simplexml-element-xpath by danbrown

From: Date: Wed, 16 Sep 2009 15:54:02 +0000
Subject: note 60522 modified in function.simplexml-element-xpath by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-160693@lists.php.net to get a copy of this message
here's a simple work-around for the lack of support for default namespaces, just overwrite the xmlns attribute of the root element: <?php $xml = simplexml_load_file('http://example.com/atom_feed.xml'); // hack to work around php 5.0's problems with default namespaces and xpath() $xml['xmlns'] = ''; // now our queries work: $titles = $xml->xpath('entry/title'); foreach ((array)$titles as $title) { print "$title\n"; } ?> --was-- here's a simple work-around for the lack of support for default namespaces, just overwrite the xmlns attribute of the root element: <?php $xml = simplexml_load_file('http://example.com/atom_feed.xml'); // hack to work around php 5.0's problems with default namespaces and xpath() $xml['xmlns'] = ''; // now our queries work: $titles = $xml->xpath('entry/title'); foreach ((array)$titles as $title) { print "$title\n"; } ?> http://php.net/manual/en/function.simplexml-element-xpath.php

« previous php.notes (#160693) next »