Creating the XML Parser Object in Mozilla

S

saraaku

Hello,

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?

Thanks
 
R

Robert Mark Bram

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?

Is this what you are referring to?

var parser = new DOMParser();
var xml = parser.parseFromString("<myNode>some valid xml</
myNode>","text/xml");

Rob
:)
 
M

Martin Honnen

saraaku said:
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');
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,002
Messages
2,570,261
Members
46,858
Latest member
FlorrieTuf

Latest Threads

Top