note 92841 modified in class.domxpath by danbrown
| From: | danbrown@php.net | Date: | Tue, 11 Aug 2009 15:17:45 +0000 |
| Subject: | note 92841 modified in class.domxpath by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-159321@lists.php.net to get a copy of this message | ||
When using DOMXPath and having a default namespace. Consider using an intermediate function to add
the default namespace to all queries:
<?php
// The default namespace: x:xmlns="http://..."
$path="/Book/Title";
$path=preg_replace("\/([a-zA-Z])","/x:$1",$path);
// Result: /x:Book/x:Title
?>
--was--
When using DOMXPath and having a default namespace. Consider using an intermediate function to add
the default namespace to all queries:
// The default namespace: x:xmlns="http://..."
$path="/Book/Title";
$path=preg_replace("\/([a-zA-Z])","/x:$1",$path);
// Result: /x:Book/x:Title
http://php.net/manual/en/class.domxpath.php