XML namespace - what is xml namespace?

what is xml namespace - the xml namespace is a collection of names that can be used as element or attribute names in an xml document.the namespace qualifies element names uniquely on the web in order to avoid conflicts between elements with the same name.the namespace is identified by some uri,either a uniform resource locator(url), or a uniform resource name(urn).the namespace declaration syntax xmlns:perfix="uri".

   <information>
                 
                      <r:table  xmlns:r="http://www.w3.org/1999/html5" >
                      
                         <r:tr>
                                 
                                 <r:td>ram</r:td>
                                 
                                 <r:td>25</r:td>
                                 
                                 <r:td>infosys</r:td>
                              
                        </r:tr>
                        
                     </r:table>
                     
                     
                     <s:table   xmlns:s="http://www.w3web.com/namespace" >
                     
                             <s:name>shyam</s:name>
                             
                             <s:age>26</s:age>
                             
                             <s:company>infosys</s:company>
                              
                    </s:table> 
                    
                    
                </information>

the xml namespace uri is not used by the parser to look up information.

you can also define namespaces against a child node.this way, you could use multiple namespaces within the same document if required.

xml namespace example

        <information     xmlns:s="http://www.w3web.com/namespace"

xmlns:r="http://www.w3.org/1999/html5" > <r:table> <r:tr> <r:td>ram</r:td> <r:td>25</r:td> <r:td>infosys</r:td> </r:tr> </r:table> <s:table> <s:name>shyam</s:name> <s:age>26</s:age> <s:company>infosys</s:company> </s:table> </information>

XML - explicit namespace

XML namespaces can be declared either explicitly or by default.with an explicit declaration, you define a shorthand, or prefix, to substitute for the full name of the namespace.

you use this prefix to qualify elements belonging to that namespace.explicit declaration are useful when a node contains elements from different namespaces.

    <books>
                    
                   <bks:book   xmlns:bks="urn:example.w3web.com:bookinfo"
xmlns:money="urn:finance:money"
> <bks:title>java books </bks:title> <bks:price money:currency="uk pond">23.45</bks:price> <bks:book> <books>

XML - default namespace

a default declaration declares a namespace to be used for all elements within its scope, and a perfix is not used.all elements and attributes in the document that do not have a prefix will then belong to the default namespace.

                    <book  xmlns="urn:default.w3web.com:info">                   
                                                           
                          <title>java books </bks:title>
                          
                          <price currency="uk pond">23.45</price>                          
                          
                 <book>