note 99032 added to domxpath.query
| From: | chrisATcmbuckleyDOTcoDOTuk at osu1 dot php dot net | Date: | Fri, 23 Jul 2010 12:21:30 +0000 |
| Subject: | note 99032 added to domxpath.query | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-171067@lists.php.net to get a copy of this message | ||
Further to the comments below about documents with default namespaces, the following function tweaks
your XPath expression for you:
<?php
function xpath(DOMNode $node, $path) {
$defaultns = 'defaultns';
$xpath = new DOMXPath($node->ownerDocument);
if (null !== $node->namespaceURI) {
$xpath->registerNamespace($defaultns, $node->namespaceURI);
$path = preg_replace('#(::|/\s*|\A)(?![/@].+?|[a-z\-]+::)#', '$1' .
$defaultns . ':$2', $path);
}
return $xpath->query($path, $node);
}
?>
----
Server IP: 92.48.74.199
Probable Submitter: 193.36.79.207
----
Manual Page -- http://www.php.net/manual/en/domxpath.query.php
Edit -- https://master.php.net/note/edit/99032
Del: integrated -- https://master.php.net/note/delete/99032/integrated
Del: useless -- https://master.php.net/note/delete/99032/useless
Del: bad code -- https://master.php.net/note/delete/99032/bad+code
Del: spam -- https://master.php.net/note/delete/99032/spam
Del: non-english -- https://master.php.net/note/delete/99032/non-english
Del: in docs -- https://master.php.net/note/delete/99032/in+docs
Del: other reasons-- https://master.php.net/note/delete/99032
Reject -- https://master.php.net/note/reject/99032
Search -- https://master.php.net/manage/user-notes.php