How do XML namespaces work without a working network connection?

后端 未结 4 1356
南笙
南笙 2020-12-05 14:28




        
4条回答
  •  误落风尘
    2020-12-05 15:05

    Let us assume we have this XML document.

    
    
          
            Your text here
          
          
            182 cm
            83 kg
          
    
    

    It includes HTML which has a body tag with a semantic meaning for a HTML renderer. It also has another body tag which carries information about a specific person. A namespace defines a semantic scope for this tag. Without a namespace(as in the example provided), it is impossible for a parser to tell the difference because they are syntactically the same.

    Here is the semantically correct version of the same document:

    
    
      
        Your text here
      
      
        182 cm
        83 kg
      
    
    

    Thus thanks to namespaces we do not have worry about conflicting tags with different meanings.

    The namespace URIs themselves are never actually resolved, and are arbitrary (thus you can use them offline).

提交回复
热议问题