note 89815 deleted from function.simplexml-element-xpath by thiago

From: Date: Tue, 24 Mar 2009 15:30:22 +0000
Subject: note 89815 deleted from function.simplexml-element-xpath by thiago
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-152393@lists.php.net to get a copy of this message
Note Submitter: pvenakis at efrontlearning dot net ---- Both notes below are very useful, thank you both! But it's not apparent what to do to access a specific value. Here's an slightly different example: <?php $xml_doc = <<<XML <?xml version='1.0'?> <!-- without namespace: --> <!-- <document> --> <!-- with default namespace: --> <manifest xmlns="uri:some_namespace"> <metadata> <schemaversion>SCORM 1.2</schemaversion> </metadata> </manifest> XML; $xml = simplexml_load_string($xml_doc); $namespaces = $xml->getNamespaces(true); // register a prefix for that default namespace: $xml->registerXPathNamespace("default", $namespaces[""]); // and use that prefix in all of your xpath expressions: $xpath_to_schemaversion = "//default:manifest/default:metadata/default:schemaversion"; var_dump($xml->xpath($xpath_to_schemaversion));

« previous php.notes (#152393) next »