[CODE] oXmlDom = document.implementation.createDocument("","",null); oXmlDom.load("something.xml");[/CODE] or
[CODE] function createDocument() { var aVersions = [ "MSXML2.DOMDocument.5.0", "MSXML2.DOMDocument.4.0","MSXML2.DOMDocument.3.0", "MSXML2.DOMDocument","Microsoft.XmlDom" ];
for (var i = 0; i < aVersions.length; i++) { try { var oXmlDom = new ActiveXObject(aVersions[i]); return oXmlDom; } catch (oError) { //Do nothing } } throw new Error("MSXML is not installed."); } [/CODE]
@A1ien51Aug 18.2008 — #I think you ansered your own question....I am not sure why you would use that over the XMLHttpRequest object. Guessing you get a null error and think another way will fix it OR you have requirements that are very strict and not smart. ?
[CODE]<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>dan's client-side xsl demo</client> </title> </head> <body onLoad="runTransform('combo.xsl', 'you can change this to another xsl file path');" >
<div id="dump"> You need to : <br /> 1. pass the right xslt file path to the runTransform funtion. <br /> 2. put the url of the xml document after a ? in the page url: the 'querystring' </div>
<script type="text/javascript"> function runTransform(ssUrl ){ var turl = window.location.search.substr(1); //load the data document url from the queryString
if(document.implementation && document.implementation.createDocument){ // Mozilla
var xsltProcessor = new XSLTProcessor();
// load the xslt file var x= new XMLHttpRequest(); x.open("GET", ssUrl , false); x.send(null);
// get the XML document xslStylesheet = x.responseXML; xsltProcessor.importStylesheet(xslStylesheet);
// load the xml file x= new XMLHttpRequest(); x.open("GET", turl, false); x.send(null);
var xmlSource = x.responseXML;
//transform var resultDocument = xsltProcessor.transformToFragment(xmlSource, document); document.getElementById("dump").innerHTML= ""; document.getElementById("dump").appendChild(resultDocument);
}else if(window.ActiveXObject){ // IE
// Load XML xml = new ActiveXObject("MSXML2.DOMDocument"); xml.async = false