XML Namespaces
Namespaces are used to avoid ambiguity between XML elements of the same name. An XML Namespace is often specified as URI Uniform Resource Identifier. Such a URI might typically look like:
http://schemas.xmlsoap.org/wsdl/http/
Namespaces are declared with an associated prefix that is then applied to a tag. When the XMLNode representation is constructed, the prefix is removed and the namespace corresponding to the prefix is set in the #namespace member of the node. When writing out an XMLNode tree, a namespace dictionary is supplied, often the same one produced when parsing the incoming XML that indicates the prefixes to be used for each namespace.
Although multiple prefixes could be used for a single namespace, on writing out the XMLNode tree only the first prefix added to a namespace dictionary is used. The following XML uses namespaces and the subsequent images show the XMLNode representation and the namespace dictionary.
<?xml version="1.0" encoding="UTF-8"?> <!-- Simple XML to do a test for well-formedness - should work --> <ans:catalog xmlns:ans="http://trihedral.com/enginetests/XML"> <ans:book id="book69"> <ans:author>Pomeroy, Steve</ans:author> <ans:title>RPC Manual</ans:title> <ans:genre>SCADA Software</ans:genre> <ans:price>44.95</ans:price> <ans:publish_date>2006-01-19</ans:publish_date> <ans:description>A guide to VTScada RPC.</ans:description> </ans:book> </ans:catalog>