Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > Creating the XML Parser Object in Mozilla

Reply
Thread Tools

Creating the XML Parser Object in Mozilla

 
 
saraaku
Guest
Posts: n/a
 
      02-11-2008
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
 
Reply With Quote
 
 
 
 
Robert Mark Bram
Guest
Posts: n/a
 
      02-12-2008
> 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

 
Reply With Quote
 
 
 
 
Martin Honnen
Guest
Posts: n/a
 
      02-12-2008
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/
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
XML::Parser Installation error: XML-Parser-2.34 Sean Perl Misc 3 10-03-2006 01:23 AM
XML::Parser Installation error: XML-Parser-2.34 Sean Perl Misc 0 10-02-2006 06:20 PM
Different results parsing a XML file with XML::Simple (XML::Sax vs. XML::Parser) Erik Wasser Perl Misc 5 03-05-2006 10:09 PM
XML-Parser to XML-Parser communication (encoding issues?) arne Perl Misc 0 09-13-2005 12:53 PM
XML Parser VS HTML Parser ZOCOR Java 11 10-05-2004 01:58 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57