Re: DOM API Namespaces - help?

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

 



Hi Nathan,

You need to retrieve the attribute based on the xmlns namespace.

Nathan Rixham wrote:
Thanks Jessen, I'm using the DOM API (domdocument) in PHP 5 - and yes pull xmlns:xi="http://www.w3.org/2001/XInclude"; from the chapter or indeed any namespaces defined in the root node and store them in a variable.

If anybody could shed any light it'd be greatly appreciated.

$xml = '<?xml version="1.0" ?>
<chapter xmlns:xi="http://www.w3.org/2001/XInclude";>
<a />
</chapter>';

$dom = new DOMDocument();
$dom->loadXML($xml);
$root = $dom->documentElement;
$attr = $root->getAttributeNS('http://www.w3.org/2000/xmlns/', 'xi');
var_dump($attr);

Rob


Nathan

Per Jessen wrote:
Nathan Rixham wrote:

but assuming the above file is:
<?xml version="1.0" ?>
<chapter xmlns:xi="http://www.w3.org/2001/XInclude";>
<a />
</chapter>

how would one retrieve xmlns:xi="http://www.w3.org/2001/XInclude";

When you say 'retrieve', what do you really mean?  You need to get the
namespace value into a PHP variable?
I would probably look at the namespace-uri() function in XSLT, but I
don't know if you're using XSLT?


/Per Jessen, Zürich

--
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