saraaku wrote:
> I tried creating the xml parser object for mozilla, firefox but have
> had a hard time doing this. When I did this initially, it worked.
> But, when I tried it again, it did not. Does spaces in the formula
> affect it?
>
> Can someone please provide me the correct formula to create this
> object and how I can check if spaces are the reason why it does not
> work?
It is not clear what you are talking about. Do you want to load XML from
a URL? Then you have to possibilities
1)
var xmlDoc = document.implementation.createDocument('', 'dummy', null);
xmlDoc.onload = function () {
// handle document here
}
xmlDoc.load('file.xml')
2)
var httpRequest = new XMLHttpRequest();
httpRequest.open('GET', 'file.xml', true);
httpRequest.onreadystatechange = function () {
if (httpRequest.readyState === 4) {
// handle httpRequest.responseXML here
}
}
httpRequest.send(null);
If you want to parse a string with XML then use
var parser = new DOMParser();
var xmlDoc = parser.parseFromString(xmlString, 'application/xml');
--
Martin Honnen
http://JavaScript.FAQTs.com/