Home Xml XML Elements
Questions:Ask|Latest


 
 

Share on Google+Share on Google+

XML Elements

Advertisement
XML Elements are extensible. They have relationships. They have simple naming rules.

XML Elements

     

XML Elements are extensible. They have relationships. They have simple naming rules.

XML Elements are Extensible

XML documents can be extended to carry more information.

 

 

 

 

 

 

Look at the following XML example:

<?xml version="1.0" encoding="ISO-8859-1"?>
<E-mail>
<To>Rohan</To>
<From>Amit</From>
<Body>Be ready for a cruise...i will catch u  tonight</Body>
</E-mail>

Let's suppose that we create an application to fetch data from the above  XML document and produce this output:

E-mail

To: Rohan
From: Amit

Be ready for a cruise...i will catch u  tonight

Now, the author wants to add a new feature (let it be a subject line). He can easily achieve it by adding one more tag ie..<Subject>in the xml document. So the new modified xml document will look like this :

<?xml version="1.0" encoding="ISO-8859-1"?>
<E-mail>
<To>
Rohan</To>
<From>Amit</From>
<Subject>Surprise....</Subject>
<Body>Be ready for a cruise...i will catch u  tonight</Body>
</E-mail>

Now the new generated output will look like this

E-mail

To: Rohan
From: Amit

Subject : Surprise....

Be ready for a cruise...i will catch u  tonight

XML Elements have Relationships

Elements in a xml document are related as parents and children.

Imagine that this xml document is a description of a e-mail:

<?xml version="1.0" encoding="ISO-8859-1"?>
<E-mail>
<To>
Rohan</To>
<From>Amit</From>
<Subject>Surprise....</Subject>
<Body>Be ready for a cruise...i will catch u  tonight</Body>
</E-mail>

Here, E-mail is the root element while To, From, Subject and Body are the child elements of the E-mail. Here, E-mail is  the parent element of  To, From, Subject and Body. To, From, Subject and Body are siblings (or sister elements) because they have the same parentage. Hence , all the XML Elements have Relationships.

XML Element Naming : Know-hows

XML elements must follow these naming conventions:

Names must not start with a number or punctuation character but it can contain letters, numbers, and other characters without spaces. Names must not start with the letters xml (or XML, or Xml, etc)

     

Advertisements

Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: May 24, 2007

Ask Questions?    Discuss: XML Elements   View All Comments

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments
DMCA.com