Thursday, 23 October 2014

Basics of XML


It is basically designed for transport and store data.

Example :

<mail>
    <from> krish</from>
    <to>ravi</to>
   <subject>wish</subject>
   <body>Hi, how are you</boday>
</mail>

It is structured xml which wraps the data between tags
  • Root element
  • Child element
  • Attribute values must be quoted.


Name space for xml:

We may have two xml documents with same root element, when we mix those two we get confuse like below

<table>
  <name>shiva</name>
</table>
<table>
  <item> car</item>
</table>



For resolving this confusion they have provided name space :

<h:table>
<h:name>shiva</h:name>
</h:table>

<v:table>
<v:item> car</v:item>
</v:table>

But before going to use name space we must have to define in xml document


<?xml version="1.0" encoding="UTF-8"?>
<root>
<h:table xmlns:h="http://www.w3.org/TR/html4/">
<h:name>shiva</h:name>
</h:table>

<v:table xmlns:v="http://www.w3schools.com/furniture">
<v:item> car</v:item>
</v:table>

</root>


Name space should be an URL, it will help you to understand the source of xml.

No comments:

Post a Comment