zaheer Posted February 29, 2008 Share Posted February 29, 2008 if i had tags like:<123:date> </123:date><module:name> somevalue </module:name>how would i be able to refer to the tag by for example date, or name, i.e. the parts after the colon.if i used the getelementbytagname (:date);would this work for this situation? Link to comment Share on other sites More sharing options...
boen_robot Posted March 1, 2008 Share Posted March 1, 2008 That's actually one of the most difficult questions to answer. What you have there are not orginary names. They are names in a namespace. The part before the ":" is the namespace prefix. Somewhere in the document, there should be an attribute named "xmlns:module" (for example), the value of which will specify what is known as a "namespace URI".Whether you can parse namespace documents or not depends entirely on the environment.IE's JScript implementation doesn't, I think, support namespaces over XML documents, despire its XML parser actually supporting namespaces. With it, you can usedocument.getElementsByTagName('date')to get all 'date' elements regardless of their namespace, and there's no real way of limiting the selecion over 'date' elements in a specified namespace.If you can use any sort of XPath engine, it should probably be namespace aware already. With it, you can specify for example //*[local-name() = 'date'] to get all "date" elements, regardless of their namespace.In PHP5, and most other server environments, there is XPath support, as well as complete DOM support, including methods like getElementsByTagNameNS() which allow you to limit the selection of elements between ones in a certain namespace.........What environment exactly do you want to use the XML in?In other words - what is the language (and its version) with which you want to parse the XML document, and is it on the server, or the client (browser)? If the client, know getting it to work in all browsers is entering h#ll's gate. Link to comment Share on other sites More sharing options...
zaheer Posted March 1, 2008 Author Share Posted March 1, 2008 doesn't matter. It was just a general question.thanx for the reply ne how. Link to comment Share on other sites More sharing options...
Les Posted May 13, 2008 Share Posted May 13, 2008 doesn't matter. It was just a general question.thanx for the reply ne how.I realize this was a general question, but prefixes, like local names, cannot start with a number, i.e., "123" -- only letters and the underscore character. See: http://www.w3.org/TR/xml-names/#NT-Prefix CzechM8 Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.