XML Format and Structure
A XML document is consist of tags and data. All data in an XML document is wrapped
by the tags. Let's see an example:
<?xml version="1.0" encoding="ISO-8859-1"?>
<customer>
<firstname>Michael</firstname>
<lastname>Smith</lastname>
<gender>male</gender>
<address>
<street>197 West Park Ave.</street>
<city>New York</city>
<state>NY</state>
<zip>11375</zip>
<country>US</country>
</address>
<phone>718-235-5670</phone>
<email>msmith278@yahoo.com</email>
</customer>
The first line is the XML declaration. It defines the XML version (1.0) and
the character set (ISO-8859). The next line uses tag "<customer>".
It is the root element of the document. The next four lines describe the child
elements () of the root: Please note that, except the first line, all tags in
the document are used in pair: opening tag and closing tag. You can assume,
from the above example, a pair of tags provide a "container", and
data or child tags are stored inside.
Also, you can assume, the structure of an XML document is defined by the relationship
between these "containers": a large container contains smaller containers.
Or you can assume the structure of an XML file as a "tree" that starts
at the root tag "customer" and branches to the leaves tags "firstname",
"lastname", "gender", "address", "phone"
and "email":
customer -> firstname
lastname
gender
address -> street
city
state
zip
country
phone
email
Please note, an XML document must contain a pair of root tags for the "parent"
element, whcih contains all other elements. You cannot have two roots in a single
XML document. All elements can have child elements:
<root>
<child1>......</child1>
<child2>
<subchild1>.....</subchild1>
<subchild2>.....</subchild2>
</child2>
</root>
|