How to write your first XML program?

XML is Extensible Markup Language. It is used to create user defined tags. This is derived from SGML(Standard Generalized Markup Language).

Do you like to create your own tags?? If the answer is yes, you try XML.

A simple XML code is given below.

It is a simple birthday message for your beloved one.

<Birthday>

  <Wishes>  Happy birthday  </Wishes>

</Birthday>

  Here, the root tag is <Birthday>. <Wishes>  is the user defined tag. This basic xml program shows you to create a root tag with elements.

To create a basic program, follow the below syntax.

Syntax:

<?xml version=”1.0”?>

<root tag>

  <element1>   </element1>

                    .

                    .

  <elementn>   <elementn>

</root tag>

 Let us write your first XML program for a school student details.

Here, student is the root tag, name of the student,class, school,place are the details. Let us consider these four as our elements. 

<?xml version=”1.0”?>

<student>

<name> Ajay </name>

<class> VIII standard </name>

<School> SS public school </School>

<place>  Chennai </place>

</student>

Note:

·       Tags are case sensitive. so, use the tags in proper case. For example, opening a  <student> tag ,you shouldn’t use ending as like </Student>,</STUDENT>.

·       In the opening statement, <?xml version=”1.0”?>. xml keyword should be in lowercase.

No comments:

Post a Comment