The XML namespace provides a way to avoid element naming conflicts.

Source: Internet
Author: User
Tags naming convention xml parser xmlns
The XML namespace provides a way to avoid element naming conflicts.
Because the elements used in XML documents 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. The XML document contains fruit information in the table element:
Apples
The XML document Bananas contains the table information (furniture, which cannot be eaten) in the table element ):
African Coffee Table 80 120
If the preceding two XML document fragments happen to be used together, a name conflict may occur. Because both parts contain
And the definition of these two table elements is different from that of the contained content.
The following XML file contains information in the table element: the XML file under Apples Bananas carries the information of the furniture table: in the preceding two examples, besides the prefix, both Table elements use the xmlns attribute to associate the elements with different namespaces.
The namespace attribute of namespaces is generally placed at the start of an element. The syntax is as follows: xmlns: namespace-prefix = "namespace" in the preceding example, the namespace defines an Internet address: xmlns: f = "http://www.w3schools.com/furniture" W3C naming convention that the namespace itself is a unified Resource Identifier, Uniform Resource Identifier (URI ).
When a namespace is used at the beginning of an element, all the child elements of the element are associated with the same namespace through a prefix.
Note: the network address used to identify the namespace is not called by the XML Parser. The XML parser does not need to find information from this network address, the network address only serves to give the namespace a unique name, so the network address can also be virtual, however, many companies often regard this network address as a real Web page, which contains more detailed information about the current namespace.

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.