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.