XML
  Home arrow XML arrow Page 5 - 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 
VeriSign Whitepapers 
VPS Hosting 
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 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
     
     
    ADVERTISEMENT

    Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here

    My First XML Document - Creating An XML Document


    (Page 5 of 6 )

    This part explores how to build an XML document. First we will begin with a simple XML document. In Part I, we have already briefly dealt with XML tags, attributes, elements, namespaces and rule-based systems of both DTD and Schemas. Albeit, writing your first XML document is going to be so easy, we are going to dive right in and write one.

    Point To Note:
    This basic XML document contains one element, called Basic. This is really the essence of XML: the ability to define your own meaning and structure to the document. So open your favorite text editor and type the content of Example 1.1.

    Example 1.1: A Basic XML Document
    <?xml version = 1.0 ?>
    <?xml-stylesheet type = text/xsl href= 
    Basic.xsl?>
    <Basic> Hello, Welcome To The XML World. </Basic>
    
    Now, save the file as HelloWorld.xml. If you are using Notepad, then in the Save as Dialog box be sure to select all files form the Save as Type drop-down list. If you dont note pad will save as .txt file, and you may not be able to open the document in an XML Processor. You can also rap the file name in quotes as an alternative.

    Next, let us develop a simple Style Sheet so we can use the file in a browser. This step isnt really necessary, because XML Parsers, including the one that comes with IE5 and onwards will parse the document and reveal its structure. But I just want to give you something here that looks familiar, and most people have by now seen a simple web page.

    Example 1.2: A Basic XSL(T) Document
    <?xml version= “1.0” ?>
    <xsl:stylesheet version= “1.0” xmlns:xsl = “http://www.w3.org/1999/XSL/Transform”>
    <!- 
    xmlns:xsl = http://www.w3.org/TR/WD-xsl for most versions of Internet Explorer 
    5 ->
    <xsl:template match= “/”>
    <html>
    <head>
    <title> A Basic Style 
    Sheet </title>
    </head>
    <body>
    <xsl:value-of select = “/” />
    </body>
    </html>
    </xsl: 
    template>
    </xsl:stylesheet> 
    
    Next, save the file as Basic.xsl in the same directoryu or folder as HelloWorld.xml. The browser must be able to access it in order to view HelloWorld.xml.

    If you have Netscape, you can choose Open File from the File menu and nagivate to the directory in which you saved HelloWorld.xml. Then Open the file in the Netscape, and the screen will have something like this.

    The file Basic.xml as rendered by Netscape: File:///c:/filepath/HelloWorld.xml

    Hello, Welcome To The XML World.


    Note: You dont have to build a Style Sheet in Netscape. Netscape will render the document using built-in style sheet based on Cascading style sheet (CSS).

    If you have IE5 or onwards, choose File-Open to navigate to HelloWorld.xml. You may need to swap the portion of the XSL code that reads xmlns:xsl= http//:www.w3.org/1999/xsl/Transform for the commented code that reads xmlns:xsl = http//www.w3.org/TR/WD-xsl and resave Basic.xmlThe page should now display looking like the screen below:

    The file HellowWorld.xml as rendered by Internet Explorer. C:\filepathHelloWorld.xml.

    Hello, Welcome to XML World.

    More XML Articles
    More By Gayathri Gokul


     

       

    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 1 hosted by Hostway