XML Namespace Program

XML (Extensible Markup Language)
 
You can use prefixes in XML, a namespace for the prefix must be defined. The namespace can be defined by  xmlns attribute in the start tag of an element.

The namespace declaration has the following syntax. xmlns:prefix="URI".
 
Name Conflicts in XML

Name conflict is called two tags and has the same name to execute the first tag only. If you write the Namespace control, it conflicts.

This often results in a conflict, when trying to mix XML documents from the different XML Applications.
 
Default Namespace In XML

Defining a default namespace for an element saves us from using the prefixes in all the child elements. In the default namespace, you cannot write the namespace, which automatically used this namespace.
 
(EX: xmlns="namespaceURI")
 
(URI) Uniform Resource Identifier

XML language uses the URL, URI and URN. A Uniform Resource Identifier (URI) is a string of the characters, which identifies an internet resource.

The most common URI is the Uniform Resource Locator (URL), which identifies an internet domain address.

The third not so common type of URI is the Universal Resource Name (URN).
 
Code 
  1. <root xmlns:h="http://www.w3.org/TR/html4/" xmlns:f="http://www.w3schools.com/furniture">  
  2.     <h:table>  
  3.         <h:tr>  
  4.             <h:td>Lion</h:td>  
  5.             <h:td>Tiger</h:td>  
  6.         </h:tr>  
  7.     </h:table>  
  8.     <f:table>  
  9.         <f:name>Box</f:name>  
  10.         <f:width>100</f:width>  
  11.         <f:height>120</f:height>  
  12.     </f:table>  
  13.     <root>  
Output

Lion
Tiger
 
Box
100
120 
X

Build smarter apps with Machine Learning, Bots, Cognitive Services - Start free.

Start Learning Now