This article mainly introduces the XML namespace, including the Declaration of the namespace and other basic knowledge in the XML getting started learning. if you need it, refer to the following article to introduce the XML namespace, including namespace declaration and other basic knowledge in XML getting started learning. For more information, see
A namespace is a group of unique names. A namespace is a mechanism for determining which element and attribute name can be assigned to a group. The namespace is identified by URI (Uniform Resource Identifier.
Namespace declaration
The namespace uses the reserved attribute declaration. This attribute name must start with xmlns or xmlns. As follows:
Syntax
The namespace starts with the keyword xmlns.
Name indicates the namespace prefix.
A url is a namespace identifier.
Example
The namespace only affects the limited areas in the document. The element that contains this declaration and all its child elements are within the namespace range. The following is a simple example of an XML namespace:
Tanmay Patil
TutorialsPoint
(011) 123-4567
Here, the namespace prefix is cont and the Identifier (URI) is www.tutorialspoint.com/profile. This means that both the element name with the cont prefix and the attribute name (including the contact element) belong to the namespace www.tutorialspoint.com/profile.
In XML, the use of a namespace involves the concept of a category, that is, the coverage of a namespace. it refers to the elements and attributes in the namespace, which are not in the namespace. The namespace can be used to limit the entire XML document or only part of the XML document.
(1). namespace limits the entire XML document
Tom
12
male
(2) namespaces are only part of the XML document.
Tom
12
male
(3) nested namespaces
Tom
12
Male
// In this example, except that the element sex is defined in the new namespace, other elements still use the original namespace.
The above is a detailed explanation of the namespace sample code in XML. For more information, see other related articles in the first PHP community!