The XML object model in Internet Explorer 5 provides support for dealing with namespaces. The following properties provide the facility to extract the namespace, prefix, and base name for a given node.
nodeName | Returns the qualified name for the node, that is, the tag name including the namespace prefix, if present. |
namespaceURI | Returns the namespace for the element. If there is no namespace on the node, "" is returned. |
prefix | Returns the prefix specified on the element or attribute. If there is no prefix specified, "" is returned. |
baseName | Returns the name of the tag, that is, the right-hand side of the colon. |
The following examples show some XML data, followed by a table showing each element and attribute, as well as their properties in the XML object model.
<BOOKS> <BOOK xmlns="urn:BookLovers.org:BookInfo"> <TITLE>A Suitable Boy</TITLE> <PRICE currency="US Dollar">22.95</PRICE> </BOOK> </BOOKS>
Node type | nodeName | namespaceURI | prefix | baseName |
---|---|---|---|---|
ELEMENT | BOOKS | BOOKS | ||
ELEMENT | BOOK | urn:BookLovers.org:BookInfo | BOOK | |
ATTRIBUTE | xmlns | xmlns | ||
ELEMENT | TITLE | urn:BookLovers.org:BookInfo | TITLE | |
ELEMENT | PRICE | urn:BookLovers.org:BookInfo | PRICE | |
ATTRIBUTE | currency | currency |
<BOOKS> <bk:BOOK xmlns:bk="urn:BookLovers.org:BookInfo" xmlns:money="urn:Finance:Money"> <bk:TITLE>A Suitable Boy</bk:TITLE> <money:PRICE money:currency="US Dollar">22.95</money:PRICE> </bk:BOOK> </BOOKS>
Node type | nodeName | namespaceURI | prefix | baseName |
---|---|---|---|---|
ELEMENT | BOOKS | BOOKS | ||
ELEMENT | bk:BOOK | urn:BookLovers.org:BookInfo | bk | BOOK |
ATTRIBUTE | xmlns:bk | xmlns | bk | |
ATTRIBUTE | xmlns:money | xmlns | money | |
ELEMENT | bk:TITLE | urn:BookLovers.org:BookInfo | bk | TITLE |
ELEMENT | money:PRICE | urn:Finance:Money | bk | PRICE |
ATTRIBUTE | money:currency | urn:Finance:Money | money | currency |
The object model also extends support for creating and removing elements and attributes by taking namespaces into account.