December 23, 2001 - Transforming XML to HTML | WebReference

December 23, 2001 - Transforming XML to HTML

Yehuda Shiran December 23, 2001
Transforming XML to HTML
Tips: December 2001

Yehuda Shiran, Ph.D.
Doc JavaScript

When you have an XML file and want to convert it to an HTML file using XSLT in Internet Explorer, you need to first load the XML file in an ActiveXObject, then load the XSLT file in separate ActiveXObject, and then finally transform the XML object to an HTML object. Here is how you load the XML file with the value returned from a Web service (event.result.value):

var xmldoc = new ActiveXObject("MSXML2.DOMDocument.3.0");
xmldoc.async = false;
xmldoc.loadXML(event.result.value);
and here is how you load the XSLT:

var xsldoc = new ActiveXObject("MXML.DOMDocument.3.0");
xsldoc.asyc = false;
xsldoc.load("./stock.xsl");
and, finally, convert the XML document to an HTML page, and put the result in the variable res:

res.innerHTML = xmldoc.transformnode(xsldoc);