<HTML>
<!-- this simple progam loads an XML document into an IE5 browser, and loops
through the nodes using a recursive function-->
<!--load a well formed document into an island-->
<XML ID="island1" SRC="md3323.xml"></XML>
<SCRIPT>
//create a document object and a node lis
var myDoc=island1
var myDocNodeList=myDoc.childNodes
if(myDoc.parseError.reason!="")
{
alert(myDoc.parseError.reason);
}
else
{
alert("valid XML document");
}
//create a root element object
var rootEl=myDoc.documentElement
//loop through it's content
var tot = 0;
var cc = 0;
x=getchildren(myDoc, cc, tot);
//================begin recursive function 'getchildren'==========================
function getchildren(node)
{
//create a child list
var x=node.childNodes;
var z=x.length;
//if
if(z!=0)
{
for(var i=0;i<z;i++)
{
if(x(i).nodeType==3)
{
document.write(x(i).nodeValue+"<br>");
getchildren(x(i));
}
else if(x(i).nodeType==1 && x(i).nodeName=="OF347" )
{
document.write(" <DIV STYLE='font-size:16pt;color:red'> ")
getchildren(x(i));
document.write(" </DIV> ")
}
else if(x(i).nodeType==1 && x(i).nodeName=="OrderDate" )
{
document.write(" <DIV STYLE='font-size:16pt;color:green'> ")
document.write("<br>Order Date<hr>");
getchildren(x(i));
document.write(" </DIV> ")
}
else if(x(i).nodeType==1 && x(i).nodeName=="ContractNo" )
{
document.write(" <DIV STYLE='font-size:16pt;color:blue'> ")
document.write("<br>Contract Number<hr>");
getchildren(x(i));
document.write(" </DIV> ")
}
else if(x(i).nodeType==1 && x(i).nodeName=="OrderNo" )
{
document.write(" <DIV STYLE='font-size:16pt;color:red'> ")
document.write("<br>Order Number<hr>");
getchildren(x(i));
document.write(" </DIV> ")
}
else if(x(i).nodeType==1 && x(i).nodeName=="IssuingOfficeContact" )
{
document.write(" <DIV STYLE='font-size:14pt;color:green'> ")
document.write("<br>Issuing Office Contact Information<hr>");
getchildren(x(i));
document.write(" </DIV> ")
}
else if(x(i).nodeType==1 && x(i).nodeName=="ShipTo" )
{
document.write(" <DIV STYLE='font-size:12pt;color:blue'> ")
document.write("<br>Ship To Contact Information<hr>");
getchildren(x(i));
document.write(" </DIV> ")
}
else if(x(i).nodeType==1 && x(i).nodeName=="Contractor" )
{
document.write(" <DIV STYLE='font-size:12pt;color:red'> ")
document.write("<br>Contractor Contact Information<hr>");
getchildren(x(i));
document.write(" </DIV> ")
}
else if(x(i).nodeType==1 && x(i).nodeName=="Item_No" )
{
cc = cc + 1;
document.write(" <DIV STYLE='font-size:12pt;color:green'> ")
document.write("<br>Item_No " + cc + "<hr>");
getchildren(x(i));
document.write(" </DIV> ")
}
else if(x(i).nodeType==1 && x(i).nodeName=="Line_Item_Info" )
{
document.write(" <DIV STYLE='font-size:12pt;color:blue'> ")
document.write("<br>Line Item Information<hr>");
getchildren(x(i));
document.write(" </DIV> ");
document.write("<h3><br>Total Number of Line Items = " + cc + "<br>");
document.write("<h3><br>Total Purchase Amount = $" + tot + "<br>");
}
else if(x(i).nodeType==1 && x(i).nodeName=="Qty_Ord" )
{
document.write(" <DIV STYLE='font-size:10pt;color:blue'> ");
document.write("<br>Quantity Ordered =" + x(i).firstChild.nodeValue + "<hr>");
document.write(" </DIV> ")
var qty = x(i).firstChild.nodeValue;
}
else if(x(i).nodeType==1 && x(i).nodeName=="Unit_Price" )
{
tot = parseFloat(parseFloat(tot) + (qty*parseFloat(x(i).firstChild.nodeValue)));
document.write(" <DIV STYLE='font-size:10pt;color:blue'> ");
document.write("<br>Purchase Amount =" + x(i).firstChild.nodeValue + "<hr>");
document.write(" </DIV> ")
}
else
{
getchildren(x(i));
}
}
}
}
//==========end function 'getchildren'===================
</SCRIPT>
</HTML>