Thank you, Rob, Unfortunately, that didn't work, either (though I'll keep it in mind). The returned string is still empty. I also unsuccessfully fetched the 'xmlns' attribute using getAttribute(). Interestingly, although hasAttributes(void) returns true, hasAttribute('xmlns'), and hasAttribute(' xml:lang') both return false. On 11/06/2008, Rob Richards <rrichards@xxxxxxxxxxxxx> wrote: > Borden Rhodes wrote: >> 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? > > The xml prefix is bound to the http://www.w3.org/XML/1998/namespace > namespace. > > $lang = > $page->documentElement->getAttributeNS('http://www.w3.org/XML/1998/namespace', > 'lang'); > > Rob > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php