Re: [PHP-XML-DEV] DomXPath and default XML namespaces

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





On 14.12.2004 6:45 Uhr, Dan Phiffer wrote:
Adam Maccabee Trachtenberg wrote:

This is an XPath FAQ. Without a ns prefix, XPath doesn't choose
elements living in the default ns, but ones living in no namespace.


Are there any good references you might point me to? I'm pretty new to this stuff and beyond my "in a Nutshell" book don't have many places to consult yet.


> what happens to:


<root> <foo> <qxx/> </foo> <foo xmlns="bar"> <qxx/> </foo> </root>

And /root/foo/qxx? Do you select qxx in the default ns? Or not?

-adam


That makes perfect sense. I'm realizing that XPaths are not as portable as I thought they were. At least not without some way of converting element prefixes easily...

You just have to learn that prefixes are just aliases to the real namespaces, then you're fine. Don't count on prefixes, they itself are meaninngless. And always use registerNamespace() for all namespaces you need in the XPath query. Then XPath is very portable.


chregu


Thanks, -Dan


-- christian stocker | Bitflux GmbH | schoeneggstrasse 5 | ch-8004 zurich phone +41 1 240 56 70 | mobile +41 76 561 88 60 | fax +41 1 240 56 71 http://www.bitflux.ch | chregu@xxxxxxxxxx | gnupg-keyid 0x5CE1DECB

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux