January 19, 2002 - The DOMDocument Graph Representation | 2

Yehuda Shiran January 19, 2002
The DOMDocument Graph Representation
Tips: January 2002

Yehuda Shiran, Ph.D.
Doc JavaScript

Converting an XML file to a graph shouldn't be too difficult. Actually, it's more like a tree. The XML tags are the nodes of this tree. Their hierarchical order determines their seats on this tree. Let's look at an example to clarify this point. Here is our mydvd.xml description:

<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="mydvd.xsl"?>
 <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="11800" />		  
     </month>
     <month>
       <name>February 2001</name>
       <week number="1" dvds_rented="11500" />
       <week number="2" dvds_rented="12390" />
       <week number="3" dvds_rented="19050" />
       <week number="4" dvds_rented="11200" />		  
     </month>
     <month>
       <name>March 2001</name>
       <week number="1" dvds_rented="15300" />
       <week number="2" dvds_rented="12390" />
       <week number="3" dvds_rented="10050" />
       <week number="4" dvds_rented="11230" />		  
     </month>
   </data>
 </sales>
Here is the tree representation of this document: