top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

How can name conflicts be avoided in XML?

0 votes
493 views
How can name conflicts be avoided in XML?
posted Jan 2, 2018 by Sathaybama

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

XML allows the user to create their own tags this can lead to conflicts if an attempt is made to mix two different XML documents from different XML applications. In order to avoid this XML uses the concept of namespaces. Which simply uses a prefix to differentiate between two similarly named tags.

For Example:

<table>
<tr>
<td>boy</td>
<td>girl</td>
</tr>
</table>
<table>
<name>Coffee Table</name>
<width>180</width>
<length>320</length>
</table>

In the above case if both the xml code was to be clubbed together there would be a naming conflict as both the tags of name consists of different content and meaning. In order to avoid this the user simply has to use namespaces.
ie the above code can be re written as:

<a:table>
<a:tr>
<a:td>boy<a:/td>
<a:td>girl<a:/td>
</a:tr>
</a:table>
<b:table>
<b:name>Coffee Table</b:name>
<b:width>180</b:width>
<b:length>320</b:length>
</b:table>

In this way no conflicts occur.

answer Jan 2, 2018 by Shivaranjini
...