The namespaces provide unique names to elements and attributes of XML. An XML document can be a collection of XML documents from various developers and different applications. If a element and attribute names coming from different documents are same, it leads to the conflict.

Example of namespace in XML

Files below have “area” as common element. In File1, area represents the area of the country. In File2 it is the area of the shape. When it has to be merged naming conflict arises.

File1.xml

<area>

    <country>Russia</country>

    <capital>Moscow</capital>

</area>

 

File2.xml

<area>

    <shape>square</shape>

    <length>10</length>

</area>

 

›› go to examples ››