Quick Tour is the same thing as "learning by examples" (Examples were taken from some other books ...)
Chapter 6 For example 6: jview /cp f:\msxml\classes;f:\msxml; msxml -i example1.xml -s example6.xsl -o e6out.htm F:\sinn\xml\ie>jview /cp f:\msxml\classes;f:\msxml; msxml Usage: jview msxml [-d|-d1|-d2|-f] [-t num] [-e encoding] [-o filename] [-c|-p] [-i] [-m] [-s] filename Version: 1.0.8 This program parses the given XML file and optionally dumps the resulting data structures to standard output. Arguments: -d Write parsed XML in original XML format. -d1 Write parsed XML in a tree format. -d2 Write schema representation of DTD. -f Fast parsing that bypasses tree building. -t Specifies how many iterations to time the parser. -o Provides a filename for dumping output. (This is needed if data is in Unicode.) -e Character encoding for output other than that of the input. -c Output in compact mode (no newlines or tabs). -p Output in pretty mode (inserts newlines & tabs). -i Switch to case insensitive. -m Perform object model test, which creates test file 'test.xml'. -s Standalone - do not load external DTD's or entities.
XML doc:
<?xml version = "1.0"?> <PCS> <PC> <NAME>Acme Blaster</NAME> <CAPACITY>100</CAPACITY> <PRICE>2000</PRICE> </PC> <PC> <NAME>Speedy PC</NAME> <CAPACITY>200</CAPACITY> <PRICE>4000</PRICE> </PC> <PC> <NAME>Gonzo PC</NAME> <CAPACITY>300</CAPACITY> <PRICE>5000</PRICE> </PC> </PCS>
HTML:
<html> <head> <title>Example 1</title> </head> <body> <h1>Example 1</h1> <p> XML Catalog displayed in an HTML table using IE4.0 XML Data Binding <applet code=com.ms.xml.dso.XMLDSO.class width=100% height=25 id=xmldso> <param name="url" value="example1.xml"></applet> <table id=table border=2 width=100% datasrc=#xmldso> <thead> <th>Name <th>Capacity <th>Price </thead> <tr> <td valign=top><div datafld=NAME></td> <td valign=top><div datafld=CAPACITY></td> <td valign=top><div datafld=PRICE></td> </tr> </table> </body> </html>
HTML:
<html> <head> <title>Example 2</title> </head> <body> <h1>Example 2</h1> <p> XML Catalog displayed in an HTML table using IE4.0 XML Data Binding <applet code=com.ms.xml.dso.XMLDSO.class width=100% height=25 id=xmldso mayscript = TURE > <!-- XML stored in the HTML page as part of an applet element --> <PCS> <PC> <NAME>Acme Blaster</NAME> <CAPACITY>100</CAPACITY> <PRICE>2000</PRICE> </PC> <PC> <NAME>Speedy PC</NAME> <CAPACITY>200</CAPACITY> <PRICE>4000</PRICE> </PC> <PC> <NAME>Gonzo PC</NAME> <CAPACITY>300</CAPACITY> <PRICE>5000</PRICE> </PC> </PCS> </applet> <table id=table border=2 width=100% datasrc=#xmldso> <thead> <th>Name <th>Capacity <th>Price </thead> <tr> <td valign=top><div datafld=NAME></td> <td valign=top><div datafld=CAPACITY></td> <td valign=top><div datafld=PRICE></td> </tr> </table> </body> </html>
XML:
<?xml version = "1.0"?> <PCS> <PC> <NAME>Acme Blaster</NAME> <CAPACITY> <RAM>10</RAM> <DISK>200</DISK> </CAPACITY> <PRICE>2000</PRICE> </PC> <PC> <NAME>Speedy PC</NAME> <CAPACITY> <RAM>50</RAM> <DISK>400</DISK> </CAPACITY> <PRICE>4000</PRICE> </PC> <PC> <NAME>Gonzo PC</NAME> <CAPACITY> <RAM>100</RAM> <DISK>500</DISK> </CAPACITY> <PRICE>5000</PRICE> </PC> </PCS>
HTML:
<html> <head> <title>Example 3</title> </head> <body> <h1>Example 3</h1> <p> XML Catalog displayed in an HTML table using IE4.0 XML Data Binding <applet code=com.ms.xml.dso.XMLDSO.class width=100% height=25 id=xmldso> <param name="url" value="example3.xml"></applet> <table id=table border=2 width=100% datasrc=#xmldso> <thead> <th>Name <th>Capacity <th>Price </thead> <tr> <td valign=top><div datafld=NAME></td> <td valign=top> <table width=100% datasrc=#xmldso datafld=CAPACITY border=2> <thead> <th>RAM <th>DISK </thead> <tr> <td><div datafld=RAM></td> <td><div datafld=DISK></td> </tr> </table> </td> <td valign=top><div datafld=PRICE></td> </tr> </table> </body> </html>
HTML:
<html> <head> <title>Example 4</title> <script language="JavaScript"> <!-- hide function FindDearest() { // Get the XML document root node object var root = xmldso.getDocument().root; // Get a list of all its children that are PCs var items = root.children.item("PC"); var num = items.length; // Initalize the dearest PC name to blank var DearestPrice = ""; // Initialize the dearest PC price to -1 var DearestPrice = -1; // Traverse the list of PCs for (i=0; i<num; i++) { // Get a list of the children of this PC var PC = items.item(i).children; // Pick up the contents of the name element var name = PC.item("NAME").text; // Pick up the contents of the price element var price = PC.item("PRICE").text; // Convert the price string into a number var p = parseInt(price); // See if this is the dearest PC we have seen if (p > DearestPrice) { // Dearest PC so far - store its details DearestName = name; DearestPrice = price; } } // Construct a string of the result msg = "Dearest PC is " + DearestName + " costing " + DearestPrice; // Return the string return msg; } // --> </script> </head> <body> <h1>Example 4</h1> <p> XML Catalog displayed in an HTML table using IE4.0 XML Data Binding <applet code=com.ms.xml.dso.XMLDSO.class width=100% height=25 id=xmldso> <param name="url" value="example1.xml"></applet> <table id=table border=2 width=100% datasrc=#xmldso> <thead> <th>Name <th>Capacity <th>Price </thead> <tr> <td valign=top><div datafld=NAME></td> <td valign=top><div datafld=CAPACITY></td> <td valign=top><div datafld=PRICE></td> </tr> </table> <form> <input type=button value="Find dearest PC" onclick='window.alert(FindDearest())'> </form> </body> </html>
HTML:
<html> <head> <title>Example 5</title> </head> <body> <h1>Example 5</h1> <p> XML Catalog displayed in an HTML table using IE4.0 XML Data Binding <applet code=com.ms.xml.dso.XMLDSO.class width=100% height=25 id=xmldso> <param name="url" value="example1.xml"></applet> <table id=table border=2 width=100%> <tr> <td><b>Name</b></td> <td><div datasrc=#xmldso datafld=NAME></td> </tr> <tr> <td><b>Capacity</b></td> <td><div datasrc=#xmldso datafld=CAPACITY></td> </tr> <tr> <td><b>Price</b></td> <td><div datasrc=#xmldso datafld=PRICE></td> </tr> </table> <form> <input type=button value="Previous" onclick='xmldso.recordset.moveprevious();'> <input type=button value="Next" onclick='xmldso.recordset.movenext();'> </form> </body> </html>