Sample Code of the namespace in XML

Source: Internet
Author: User
Tags tutorialspoint
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!

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.