Multiple namespaces in XML can be declared for various elements, child elements, attributes and contents in a document.  Multiple namespaces are helpful to merge multiple documents or multiple DTDs into one document When multiple namespaces are declared, a namespace’s scope is limited within the elements where namespace is declared.

Example of multiple namespaces

<e:area xmlns:e="http://www.earth.com/">

    <c:country xmlns:c="http://www.earth.com/country/">

        <c:name>India</c:name>

        <c:capital>Delhi</c:capital>

    </c:country> 

    <e:population>110 billion</e:population>

</e:area>

The above example has the root element “area” defined in namespace “a”. It has “country “ and “population” as child elements. Country is defined in another namespace “c”. Hence the child elements of country, the “name" and “capital” has “c” as namespace. XML parsers determine namespace from URI than prefixes.

 

›› go to examples ››