Home arrow XML arrow Page 6 - My First XML Document

Tools For The Trade - XML

We have dealt with some basic XML concepts already, so now we are prepared to leap forward and take a closer look at this powerful language. The X in XML stands for eXtensible- in other words, the language can be extended to meet the requirements of a specific situation.

  1. My First XML Document
  2. Tools For Browsing XML
  3. Tools For Parsing XML
  4. Microsoft XML Parser
  5. Creating An XML Document
  6. Tools For The Trade
By: Gayathri Gokul
Rating: starstarstarstarstar / 26
September 22, 2003

print this article


Now let us see an Example of XML Document to illustrate all that we are learnt so far in Part I and II emphasizing on Syntax Element (just numbered each line for easy explanation).

Example 2.1:
1.<?xml version = “1.0” encoding = “UTF-8”>
2.<!DOCTYPE addresslist SYSTEM 
“addresslist.dtd” [
3.<!ENTITY oldlist System “oldaddresslist.xml>
7. <name> Adam Hall </name>
8. <address> 123 Green Street 
9. <city> Pompano Beach </city>
10. <state> FL </state>
<zipcode> 12345 </zipcode>
12. </employee>
13. <employee>
14. <name> 
Mary Joseph </name>
15. <address> 63 Belle Street </address>
16. <city> 
Delray Beach </city>
17. <state> FL </state>
18. <zipcode> 12210 </zipcode>
20. &oldlist:
Example 2.2: The file oldaddresslist.xml that is referenced as an external entity on line 3 of example 2.1.
<?xml version = “1.0” encoding = “UTF-8”>
<name> Nelson 
Turner </name>
<address> 344 Main Street </address>
<city> Boca Raton 
<state> FL </state>
<zipcode> 33445 </zipcode>
Jacky Chan</name>
<address> 2345 Lake Street </address>
<city> Deerfield 
Beach </city>
<state> FL </state>
<zipcode> 12556</zipcode>
The functions of tags in Example 2.1 are as follows:

Line 1: This is the processing instruction that informs XML processor that the file adheres to XML version 1.0 and that the file uses the character encoding known as UTF-8.

Line 2: This is the start of a multi line DOCTYPE. This type of tag is used for various purposes and often contains other tags. On this line tag specifies that the document is of type “addresslist” and that it follows the data model that is define in the DTD located in the file addresslist.dtd. In this case the name of the document type and the name of DTD are the same, but they need not be so. Note that the DTD file addresslist.dtd is not presented here, its name is used only to demonstrate the DOCTYPE tag.

Line 3: This is an ENTITY tag, which is contained within the DOCTYPE tag. It declares reference to an external file. Specifically, it defines the term “oldlist” to refer to the file oldaddresslist.xml.

Line 4: This marks the end of the DOCTYPE tag.

Line 5: This tags marks the beginning of the content portion of the document, of type “addresslist”. Note the name of this tag must be the same as the name specified in the DOCTYPE tag (line 2). This is the document’s root element.

Line 6: This tag marks the beginning of a unit of data called “employee”.

Line 7 through 11: These lines contains tags and datas that define the information belonging to the this “employee” unit.

Line 12: This tag marks the end of the “employee” unit of data.

Line 13 through 19: The data and data on these lines define a second “employee” unit of data.

Line 20: This line references the “oldlist” entity that was declared in line 3. It is marked as an entity referenced by the leading (&) and the ending semicolon (;). The effect of this line will be pretty much the same as if the content of the file oldaddresslist.xml were cut and pasted into the document at this location.

Line 21: This final tag marks the end of the “addresslist” document.

Hope this part of the tutorial had provided an overview of the “XML World”. XML is deceptively simple in principle, but it is this very simplicity that is the root of its tremendous power and flexibility for representing structured data. In the next part we will deal elaborately on Data Modeling in DTDs and later move up to Data Modeling in XDR Schemas.

>>> More XML Articles          >>> More By Gayathri Gokul

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort


- Google Docs and Xpath Data Functions
- Flex Array Collection Sort and Filtering
- The Flex Tree Control
- Flex List Controls
- Working with Flex and Datagrids
- How to Set Up Podcasting and Vodcasting
- Creating an RSS Reader Application
- Building an RSS File
- An Introduction to XUL Part 6
- An Introduction to XUL Part 5
- An Introduction to XUL Part 4
- An Introduction to XUL Part 3
- An Introduction to XUL Part 2
- An Introduction to XUL Part 1
- XML Matters: Practical XML Data Design and M...

Developer Shed Affiliates


Dev Shed Tutorial Topics: