XML DOM problem with getAttribute(string)
| From: | Borden Rhodes | Date: | Wed, 11 Jun 2008 08:54:52 +0000 |
| Subject: | XML DOM problem with getAttribute(string) | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-275222@lists.php.net to get a copy of this message | ||
Hullo!
I'm having a pig of a time trying to figure this one out: I have an
XHTML document which I've loaded into a DOMDocument because I want to
add more tags to it. However, since I live in a bilingual country, I
want to get the document's xml:lang attribute so I know what language
to add my new tags in.
I want to write
$lang = $page->documentElement->getAttribute('xml:lang');
OR
$lang = $page->documentElement->getAttributeNS('xml', 'lang');
but both of these return empty strings, indicating that it cannot find
the xml:lang attribute. And yet,
$page->documentElement->hasAttributes() returns true and
$page->documentElement->attributes->getNamedItem('xml:lang')->nodeValue;
works correctly. So why doesn't my preferred code?
With thanks,