XML – Syntax

Many confuse with HTML and XML. Let me clear it here, HTML is Hyper Text Mark-up Language which is used for design web pages where as XML extensible Mark Language is used for store or carry the data in simple format.It is just the markup language which holds the data between tags.

Syntax:

Please find the below syntax to create an XML document which contains the Customer data.

<?xml version="1.0" encoding="UTF-8"?>

<customer_list> 
   
   <customer> 
      <name>Sanjay</name> 
     <location>Mumbai</location> 
   </customer> 
   
    <customer> 
      <name>Micheal</name> 
      <location>Washington</location> 
    </customer> 
   
    <customer> 
      <name>Maya</name> 
      <location>Delhi</location>  
    </customer> 
   
    <customer> 
      <name>Hari</name> 
      <location>NewYork</location>  
    </customer> 
 
</customer_list>

Please find the below syntax to create an XML document which contains the Stock data.

<?xml version="1.0" encoding="UTF-8"?> 
<portfolio> 
  <stock exchange="BSE"> 
    <name> ABCD Corp</name> 
    <symbol> A</symbol> 
    <price dt:dt="number"> 3242</price> 
  </stock> 
  <stock exchange="BSE"> 
    <name> TATA corp</name> 
    <symbol> B</symbol> 
    <price dt:dt="number"> 2343</price> 
  </stock> 
  <stock exchange="BSE"> 
    <name> Voxwagan Corp</name> 
    <symbol> C</symbol> 
    <price dt:dt="number"> 3423</price> 
  </stock> 
  <stock exchange="BSE"> 
    <name> Wipro corp</name> 
    <symbol> w</symbol> 
    <price dt:dt="number"> 1324</price> 
  </stock> 
</portfolio>