The Microsoft XML Parser (Msxml) provides support for associating elements and attributes with namespaces. There are two ways to declare namespaces: default declaration and explicit declaration.
The default declaration declares a namespace for all elements within scope. For example:
<BOOK xmlns="urn:BookLovers.org:BookInfo"> <TITLE></TITLE> </BOOK>
The following example declares the BOOK element and all elements and attributes within it. (TITLE, PRICE, and currency are from the namespace "urn:BookLovers.org:BookInfo".) The attribute xmlns is an XML keyword and is understood by the parser to be a namespace declaration:
<BOOK xmlns="urn:BookLovers.org:BookInfo"> <TITLE>A Suitable Boy</TITLE> <PRICE currency="US Dollar">22.95</PRICE> </BOOK>
Default declarations are useful when a node (element and child elements) is from the same namespace.
An explicit declaration defines a shorthand, or prefix, to substitute for the full name of a namespace. Use an explicit declaration to reference a node from a namespace separate from your default namespace.
The following example declares "bk" and "money" to be shorthand for the full names of their respective namespaces. All elements beginning with "bk:" or "money:" are considered to be from the namespace "urn:BookLovers.org:BookInfo" or "urn:Finance:Money," respectively.
<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>
Explicit declarations are useful when a node contains elements from different namespaces.