Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Microsoft.XMLDOM?

Status
Not open for further replies.

corsair2

IS-IT--Management
Feb 21, 2001
55
GB
I've only recently started using JavaScript and found the following on the W3C site which I've edited to run with files on my local drive -

<html><body><script language=&quot;javascript&quot;>// Load XML var xml = new ActiveXObject(&quot;Microsoft.XMLDOM&quot;)xml.async = falsexml.load(&quot;C:\\MyXMLDoc.xml&quot;)// Load the XSLvar xsl = new ActiveXObject(&quot;Microsoft.XMLDOM&quot;)xsl.async = falsexsl.load(&quot;C:\\MyXSLDoc.xsl&quot;)// Transformdocument.write(xml.transformNode(xsl))</script></body></html>

Nothing happens!
What type of newbie blooper am I committing?
Please help, as I need this kind of dynamic, client-side selection for some reports I'm preparing and I'm convinced JavaScript is the way to go.
When opening the xml file with the location of the xsl file hard-coded inside it displays correctly.

Thanks in advance
 

Are the xml file and xsl file well formed, closing tags, xml declarations etc ?

Are you using ie 5.+ ?
 
Hi Simon

Yes, both are well-formed and I'm using IE6

Regards
 



ok lets go back to basics then -


var xml = new ActiveXObject(&quot;Microsoft.XMLDOM&quot;)
xml.async = false
xml.load(&quot;C:\\MyXMLDoc.xml&quot;)
var xsl = new ActiveXObject(&quot;Microsoft.XMLDOM&quot;)
xsl.async = false
xsl.load(&quot;C:\\MyXSLDoc.xsl&quot;)

alert(xml.xml)
alert(xsl.xsl)

document.write(xml.transformNode(xsl)
 



ok lets go back to basics then -


var xml = new ActiveXObject(&quot;Microsoft.XMLDOM&quot;)
xml.async = false
xml.load(&quot;C:\\MyXMLDoc.xml&quot;)
var xsl = new ActiveXObject(&quot;Microsoft.XMLDOM&quot;)
xsl.async = false
xsl.load(&quot;C:\\MyXSLDoc.xsl&quot;)

alert(xml.xml)
alert(xsl.xml)

document.write(xml.transformNode(xsl)
 
Dear Simon

I've added the 'alert..' as you suggested and got the following result when running the Javascript;
First alert generates an info box with no message,
Second generates an info box with the message 'undefined'.

Next an error box comes up with the following;
&quot;Ln19.
Char.5
Error: The stylesheet does not contain a document element. The stylesheet may be empty, or it may not be a well-formed xml document.&quot;

I've checked both document and stylesheet for well-formedness using XMLwriter and both are pronounced ok.

I've also tried the xml/xsl from the w3c site with the same results when opening from javascript (but ok when opening the xml document from IE6).

Hope this helps and many thanks for your interest.
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Sponsor

Back
Top