SunQuest
 
       XML
  Home arrow XML arrow Page 6 - My First XML Document
Dev Shed Forums 
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Sun Developer Network 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Actuate Whitepapers 
Moblin 
VPS Hosting 
Weekly Newsletter

 
Developer Updates  
Free Website Content 
IBM developerWorks
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
XML

My First XML Document
By: Gayathri Gokul
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 24
    2003-09-22

    Table of Contents:
  • My First XML Document
  • Tools For Browsing XML
  • Tools For Parsing XML
  • Microsoft XML Parser
  • Creating An XML Document
  • Tools For The Trade

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
    IBM developerWorks
     
    ADVERTISEMENT

    AT&T devCentral & BlackBerry(r) Webcast Series: BlackBerry and GPS -Build Location Awareness into your BlackBerry Applications, July 10th -1:00PM EST. Register Today!

    My First XML Document - Tools For The Trade


    (Page 6 of 6 )

    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>
    4.]>
    5.<adresslist>
    6. 
    <employee>
    7. <name> Adam Hall </name>
    8. <address> 123 Green Street 
    </address>
    9. <city> Pompano Beach </city>
    10. <state> FL </state>
    11. 
    <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>
    19. 
    </employee>
    20. &oldlist:
    21.</addresslist>
    
    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”>
    <employee>
    <name> Nelson 
    Turner </name>
    <address> 344 Main Street </address>
    <city> Boca Raton 
    </city>
    <state> FL </state>
    <zipcode> 33445 </zipcode>
    </employee>
    <employee>
    <name> 
    Jacky Chan</name>
    <address> 2345 Lake Street </address>
    <city> Deerfield 
    Beach </city>
    <state> FL </state>
    <zipcode> 12556</zipcode>
    </employee>
    
    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.
    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

     

       

    XML ARTICLES

    - 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...
    - Practical XML Data Design and Manipulation f...
    - SimpleXML
    - XForms Basics, Part 3
    - XForms Basics, Part 2
    - XForms Basics





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway