WebDeveloper.com ®: Where Web Developers and Designers Learn How to Build Web Sites, Program in Java and JavaScript, and More!   
Web Developer Resource DirectoryWebDev Jobs  
Animated GIFs
CSS
CSS Properties
Database
Design
Flash
HTML
HTML 4.01 Tags
JavaScript
.NET
PHP
Reference
Security
Site Management
Video
XML/RSS
WD Forums
 Client-Side
  Development

    CSS
    Graphics
    HTML
    JavaScript
    XML
    Dreamweaver/FrontPage
    Multimedia
    Web Video
    General
    Accessibility

 Server-Side
  Development

    ASP
    Perl
    PHP
    .NET
    Java
    SQL
    Other

 Web Development
  Business Issues

    Business Matters
    Website Reviews

 E-Commerce
    Domain Names
    Search Engines

 Etc.
    Computer Issues
    Forum Software
    Feedback
    The Coffee Lounge



Script Downloads
Simple Age Calculator

Featured: October 6, 2008
Description: This is a simple PHP function that calculates the age of someone, in years.

Get Script

Hosting Search
Unix   Windows
PHP   Webmail

Sign up for the free WebDeveloper E-mail newsletter!


JupiterWeb Commerce
Partners & Affiliates
Partner With Us















internet.com
IT
Developer
Internet News
Small Business
Personal Technology
International

Search internet.com
Advertise
Corporate Info
Newsletters
Tech Jobs
E-mail Offers

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) > ]




Acceptable Use Policy

JupiterOnlineMedia

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info


Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

Web Hosting | Newsletters | Tech Jobs | Shopping | E-mail Offers