Web Services, Part V: XML and XSLT Programming: Interpreting XML - Doc JavaScript | WebReference

Web Services, Part V: XML and XSLT Programming: Interpreting XML - Doc JavaScript


Web Services, Part V: XML and XSLT Programming

Interpreting XML

The XML format is focused on the data itself. It may be structured in a very deep hierarchy. The following XML file contains the sales figures of MyDVD Rental Store Corporation for the months of January, February, and March of 2001. Notice how each piece of data is enclosed within a specific tag pair. The whole report is enclosed within the <sales> tag pair. The summary portion of the report is enclosed in a <summary> pair. Each line of the summary got its own tag pair. The data section is paired between <data> tags. Similarly, we have a tag pair for each month and for each week. The actual sales numbers are shown at the leaf cells of the hierarchy, within the <week> tag pair:

<?xml version="1.0" ?>
  <sales>
    <summary>
      <heading>MyDVD Rental Store</heading>
      <subhead>Periodical Sales Report</subhead>
      <description>Sales report for January, February, 
	           and March of 2001</description>
    </summary>
    <data>
      <month>
        <name>January 2001</name>
        <week number="1" dvds_rented="12000" />
        <week number="2" dvds_rented="15000" />
        <week number="3" dvds_rented="18000" />
        <week number="4" dvds_rented="11000" />		  
      </month>
      <month>
        <name>February 2001</name>
        <week number="1" dvds_rented="11000" />
        <week number="2" dvds_rented="12390" />
        <week number="3" dvds_rented="10050" />
        <week number="4" dvds_rented="11200" />		  
      </month>
      <month>
        <name>March 50</name>
        <week number="1" dvds_rented="11000" />
        <week number="2" dvds_rented="12390" />
        <week number="3" dvds_rented="10050" />
        <week number="4" dvds_rented="11200" />		  
      </month>
    </data>
  </sales>

Next: How to convert XML to HTML

http://www.internet.com


Produced by Yehuda Shiran and Tomer Shiran
All Rights Reserved. Legal Notices.
Created: December 31, 2001
Revised: December 31, 2001

URL: http://www.webreference.com/js/column100/3.html