Xmlns, xmlns: xsi

Source: Internet
Author: User
Tags xml parser

Xmlns, xmlns: xsi

Xmlns is the abbreviation of XML Namespaces. The Chinese name is The namespace of XML (a subset of standard General Markup Language.

Cause

For example:

The following XML document carries the information in a table:

Table

Tr

TdApples/td

TdBananas/td

/Tr

/Table

The following XML document carries information about the table (a piece of furniture ):

Table

NameAfrican Coffee Table/name

Width80/width

Length120/length

/Table

If the two XML documents are used together, because both documents contain table elements with different content and definitions, a name conflict occurs. The XML Parser cannot determine how to handle such conflicts.

To solve the above problem, xmlns is generated.

Syntax: xmlns: namespace-prefix = namespaceURI

Let's take the above example to explain how to use xmlns

This XML document carries the information in a table:

H: table xmlns: h = url 1

H: tr

H: tdApples/h: td

H: tdBananas/h: td

/H: tr

/H: table this XML document carries information about a piece of furniture:

F: table xmlns: f = url 2

F: nameAfrican Coffee Table/f: name

F: width80/f: width

F: length120/f: length

/F: The table is different from the prefix. We add an xmlns attribute to the table tag, so that a qualified name associated with a namespace is assigned to the prefix.

Xmlns attributes

The XML namespace attribute is placed in the start tag of the element and uses the following syntax:

Xmlns: namespace-prefix = namespaceURI.

When a namespace is defined in the start tag of an element, all child elements with the same prefix are associated with the same namespace.

Note: The address used to indicate the namespace will not be used by the parser to find information. The only function is to assign a unique namespace name. However, many companies often use namespaces as pointers to point to existing webpages that contain information about namespaces.

Official concepts:Xmlns is the abbreviation of xml namespace, that is, XML namespace. The xmlns attribute can be used to define one or more available namespaces in the document. This attribute can be placed in the start tag of any element in the document. The value of this attribute is similar to a URL, which defines a namespace. the browser will use this namespace for all content in the element where the property is located.

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 is used only to give the namespace a unique name, so the network address can also be virtual.

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.