Siimple XML Program. Rules must be followed while writing XML.

Leave a Comment

In XML we can create our own tags. In fact XML allows the programmer to create markup for virtually any type of information. For example : Here is our first XML program which can be written using notepad or using some standard XML editor.

XML Document 5.1 [name: first.xml]
<Person>
   <Personal-Info>
       <Name>My Name is Anuradha</Name>
       <City>I live in Pune</City>
   </Personal-Info>
   <Hobby>
       <first>I like reading</first>
       <second>I like programming</second>
       <third>I like singing</third>
   </Hobby>
</Person>

Now open some web browser like internet explorer or Mozilla Firefox and just observe the output of above program.

The file name extension used for xml program is .xml. Hence the name of above program is first.xml. The XML scripts are self descriptive. As you can see that the inforamation being displayed on the web page is about a person whose name is Anuradha. This person lives in city Pune and her hobbies are reading, programming and singing.

Rules that must be followed while writing XML -


  1. XML is a case sensitive. For example -
    <hobby>I like drawing</Hobby> or <Hobby>I like drawing</hobby> or
    is not allowed because the words hobby and Hobby are treated differently.
  2. In XML each start tag must have matching and tag. For example -
    <staring> XML is funny to write
    <simple> It is simple to implement. </simple>
    That means a closing tag is a must.
  3. The elements in XML must be properly nested. For example -
    <one> <two>Hello how are you?</one> </two> is wrong but
    <one> <two>Hello how are you?</two> </one> is correct.


0 comments:

Post a Comment