December 26, 2001 - Interpreting XML | WebReference

December 26, 2001 - Interpreting XML

Yehuda Shiran December 26, 2001
Interpreting XML
Tips: December 2001

Yehuda Shiran, Ph.D.
Doc JavaScript

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. 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>