PDA

View Full Version : MSXML2 DOMDocument


confused
05-23-2010, 09:13 AM
I know there is probably a realy simple solution to this question however I can not seem to find it on the net.

Basicly I have a XML doc that I want to read in via javascript however, when running the js in a debugger i always errors (steps out) on the
var xmlDoc = new ActiveXObject("MSXML2.DOMDocument.3.0"); line.

I really have no idea why. any help would be apprciated.
Thanks


var xmlDoc = new ActiveXObject("MSXML2.DOMDocument.3.0");
xmlDoc.async="false";
xmlDoc.load("../SaleData/ForSale.XML");
var items=xmlDoc.documentElement;

ranjan
05-24-2010, 08:38 AM
1. Are you looking for a cross browser solution ( your code would work only in IE )
2. Have you considered XMLHttpRequest instead of loading xml using .load
3. What is the exact error

confused
05-24-2010, 02:03 PM
Yeah was running it in Firefox, what was confusing was the fact it worked nicely in dirty IE. Dont really know anything about XMLHttpReques, tbh im learning as i go about parsing XML all kinda new for me.

ranjan
05-25-2010, 01:14 AM
Simply put XMLHttpRequest is a javascript method (function) that does pretty much what its called. It requests and loads an XML (and text) document requested over the http protocol.

Usual http request generally refresh the page after getting a response, with XMLHttpRequest the page doesn't need to refresh, hence this is the base function on which AJAX works.

To learn more about loading and parsing XML using AJAX please see

1. http://www.webpasties.com/xmlHttpRequest/ (pure javascript)
2. http://www.switchonthecode.com/tutorials/xml-parsing-with-jquery (with jQuery)