I'm not sure your characterization of the behavior of getElementsByTagName() is accurate. There's a getElementsByTagNameNS() that takes namespace into account, but I'm not sure getElementsByTagName() does. Did you try it?
-----Original Message----- From: Axelle Apvrille (LMC) [mailto:[EMAIL PROTECTED] Sent: Friday, February 28, 2003 12:03 PM To: [EMAIL PROTECTED] Subject: Retrieving a specific element in an XML doc, when it belongs to a namespace. I've got another question... regarding namespaces. If I'm parsing an XML document such as this one: <?xml version='1.0' encoding='ascii'?> <dsi:Information xmlns='http://www.w3.org/2001/XMLSchema' xmlns:dsi='http://www'> <dsi:Alarm>toto</dsi:Alarm> </dsi:Information> How can I retrieve directly the Alarm node ? I mean, I can request ->getElementsByTagName( ... dsi:Alarm ); but the problem is that to do so, I need to know the prefix that the user has chosen in his XML document for the corresponding namespace. If I do that, and somebody asks me to parse: <?xml version='1.0' encoding='ascii'?> <z:Information xmlns='http://www.w3.org/2001/XMLSchema' xmlns:z='http://www'> <z:Alarm>toto</z:Alarm> </z:Information> Of course, it won't work... I saw the getPrefix(), getNamespaceURI() and getLocalName()methods of DOMNode, but does this mean I should parse through _all_ nodes of my XML document, and check for each node whether it's local name is Alarm, and check the namespace URI matches the one I'm expecting ? Isn't there a shortcut ? Thanks, Axelle. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
