WebDeveloper.com �: Where Web Developers and Designers Learn How to Build Web Sites, Program in Java and JavaScript, and More!   
Web Developer Resource Directory WebDev Jobs
Animated GIFs
CSS Properties
HTML 4.01 Tags
Site Management
WD Forums

    Web Video
    Expression Web



    Forum, Blog, Wiki & CMS

 Site Management
    Domain Names
    Search Engines
    Website Reviews

 Web Development
  Business Issues

    Business Matters

    The Coffee Lounge
    Computer Issues

XML Does It Your Way!
Part 3

by Scott Clark

ActiveX for the Masses

Whether or not you use Java or ActiveX to parse your XML document, you won't actually be presenting the XML document to the browser directly. What you'll do is point the ActiveX component (or Java applet) to the XML file, and, if you're using the ActiveX parser, to the XSL file as well:

 <OBJECT ID="XSLControl" CLASSID="CLSID:2BD0D2F2-52EC-11D1-8C69-0E16BC000000" codebase="http://www.microsoft.com/xml/xsl/msxsl.cab" style="display:none"> <PARAM NAME="documentURL" VALUE="article.xml"> <PARAM NAME="styleURL" VALUE="xs.xsl"> </OBJECT> 
You'll need to define a division to target:
 <DIV id=xslTarget> </DIV> 
And then, last but not least, you'll need to add a little scripting which tells the parser to display the XML page within the DIV target:
 <SCRIPT FOR=window EVENT=onload> var xslHTML = XSLControl.htmlText; document.all.item("xslTarget").innerHTML = xslHTML; </SCRIPT> 

The MS Java XML Parser

If you think that the ActiveX parser is a bit imposing to use, don't dispair. The Java XML parser that has been shipping with MSIE4+ is also a handy little tool to use, especially since it's already on the system of everyone that's using MSIE4, and it won't have to be downloaded. Unlike the ActiveX parser, it doesn't have to use an XSL sheet to format the XML. Rather, it can use some proprietary HTML parameters for its formatting:
 <applet code=com.ms.xml.dso.XMLDSO.class width=100% height=25 id=xmldso MAYSCRIPT=true> <PARAM NAME="url" VALUE="article.xml"> </applet> <table id=table border=2 width=100% datasrc=#xmldso cellpadding=5> <thead> <th>Author <th>Title <th>Publisher <th>Pages <th>Price </thead> <tr> <td valign=top><div datafld=AUTHOR dataformatas=HTML></td> <td valign=top><div datafld=TITLE dataformatas=HTML></td> <td valign=top><div datafld=PUBLISHER dataformatas=HTML></td> <td valign=top><div datafld=PAGES dataformatas=HTML></td> <td valign=top><div datafld=PRICE dataformatas=HTML></td> </tr> </table> 
It points to the same XML file (article.xml) that the ActiveX parser was using. Again, the DTD need not even be there as far as the Microsoft Java applet is concerned, but to create valid XML you must include it anyway. The TABLE is bound to a datasource which is actually the Java parser applet's ID. Further, each data cell in the table is bound to a "field" (datafld=PRICE) from the XML file, and it is displayed as HTML (dataformatas=HTML).

The MS Java XML Parser is extremely simple to set up, and the uses are virtually limitless. If Microsoft is trying to bribe us into using MSIE by including useful little applets like this with the browser, it's working. It's up to Java developers to create an equivelent applet (hopefully 100% compatible) for Netscape's Navigator.

[ < XML Does It Your Way!:
Part 2 (MSIE4 Does XML!) ]
[ XML Does It Your Way!:
Part 4 (XML References, Links and Tools) > ]

HTML5 Development Center

Recent Articles