Why?
As with other languages, namespaces allow you to de-clutter the global namespace. This then allows for more than one element or attribute with the same name, provided it is in a different namespace.
Do you always need to qualify an element's namespace?
If you have a 'dominant' namespace containing most of the elements (e.g. http://www.w3.org/TR/html4/
), then you can change the default the namespace to this dominant namespace, like so:
<z:root xmlns="http://www.w3.org/TR/html4/" xmlns:f="http://www.w3schools.com/furniture" xmlns:z="">
<table>
<tr>
<td>Apples</td>
<td>Bananas</td>
</tr>
<f:name>African Coffee Table</f:name>
<f:width>80</f:width>
<f:length>120</f:length>
</f:table>
</z:root>
Note that we need to move root back into the global namespace to keep it equivalent to the original document.