The XML namespace provides a way to avoid element naming conflicts.
Name conflict
Because the elements used in the XML document are not fixed, two different XML documents may use the same name to describe different types of elements. In this case, naming conflicts often occur. See the following two examples.
This XML document contains fruit information in the table element:
<Table>
<Tr>
<Td> Apples </td>
<Td> Bananas </td>
</Tr>
</Table>
This XML document contains the table information (furniture, which cannot be eaten) in the table element ):
<Table>
<Name> African Coffee Table </name>
<Width> 80 </width>
<Long> 120 </length>
</Table>
If the preceding two XML document fragments happen to be used together, a name conflict may occur. Because both fragments contain <table> elements, the definitions of these two table elements are different from those of the contained content.
Use a prefix to solve naming conflicts
The following XML document contains information in the table element:
<H: table>
<H: tr>
<H: td> Apples <H: td> Bananas </H: tr>
</H: table>
The following XML document carries the furniture table information:
<F: table>
<F: name> African Coffee Table </f: name>
<F: width> 80 </f: width>
<F: length> 120 </f: length>
</F: table>
Now there is no element naming conflict problem, because the two documents use different prefixes for their respective table elements. The table elements in the two documents are respectively (By using the prefix, we create two different table elements.
Use namespace
The following XML document contains information in the table element:
<H: table xmlns: h = "http://www.w3.org/TR/html4/">
<H: tr>
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.