What is xmlns in XAML file ?


“xmlns” stands for XML namespaces. It helps us to avoid name conflicts and confusion in XML
documents. For example consider the below two XML which have table elements, one table is a
HTML table and the other represents a restaurant table. Now if both these elements come in a
single XML document there would name conflicts and confusion.

<table>
<tr><td>Row1</td></tr>
<tr><td>Row2</td></tr>
</table>
<table>
<cloth>red</cloth>
<serve>Tea</serve>
</table>

So to avoid the same we can use XML namespaces. You can see in the below XML we have
qualified the HTML table with “h:table” and the restaurant table element qualified with
“r:table”.

<h:table xmlns:h="http://www.w3.org/TR/html4/">
<tr><td>Row1</td></tr>
<tr><td>Row2</td></tr>
</h:table>
<r:table xmlns:h="http://www.questpond.com/restaurant/table/def">
<cloth>red</cloth>
<serve>Tea</serve>
</r:table>