Jump to content

tag names.


zaheer

Recommended Posts

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

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

  • 2 months later...
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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...