note 93024 deleted from class.domxpath by danbrown
| From: | danbrown@php.net | Date: | Wed, 19 Aug 2009 22:01:14 +0000 |
| Subject: | note 93024 deleted from class.domxpath by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-159665@lists.php.net to get a copy of this message | ||
Note Submitter: kermodebear (at) gmail dot com
----
If your document declares a namespace at all - even just a single default namespace
(xmlns="etc"), you MUST register that namespace with XPath, and you MUST use that
registered namespace in your query. For example:
<?xml version="1.0" encoding="UTF-8"?>
<document xmlns="http://www.whatever.com/">
<foo>
<bar>Text</bar>
</foo>
</document>
//foo will not work - you will not be able to pull data from this document without registering the
default namespace and making up a prefix for it.
If you're attempting to process arbitrary XML documents and you don't know the namespaces
beforehand (as I am in my application), use a bit of regex to pull them out then add them
dynamically.
I think this is pretty silly.