Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

creating the parseObject in Mozilla

0 views
Skip to first unread message

sar...@yahoo.com

unread,
Dec 15, 2007, 12:19:47 PM12/15/07
to dev-te...@lists.mozilla.org
How do I create an instance of the XML parser in Mozilla or load an xml document into the mozilla browser?

Is there a formula for this?

thanks


Find the Lowest Price on Thousands of Products & Save More
Shop http://salerack.googlepages.com/lowestprices.html or Click Here

Have Fun Getting Into Shape in 2008, visit FunFitness Visit: http://astore.amazon.com/funfitness-20 or Click Here


---------------------------------
Never miss a thing. Make Yahoo your homepage.

Martin Honnen

unread,
Dec 16, 2007, 7:43:36 AM12/16/07
to
sar...@yahoo.com wrote:
> How do I create an instance of the XML parser in Mozilla or load an
> xml document into the mozilla browser?

If you want to parse from a string use
var xmlDoc = new DOMParser().parseFromString(yourXmlString,
'application/xml');

If you want to parse from a file or URL then you have two options:
1) create an XML DOM document and call its load method:
var xmlDoc = document.implementation.createDocument('', 'root', null);
xmlDoc.onload = function () {
// access DOM here
};
xmlDoc.load('file.xml');
Note that loading by default happens asynchronously so you need to set
up an onload handler as shown above.

2) use XMLHttpRequest and access the responseXML property:
var httpRequest = new XMLHttpRequest();
httpRequest.onreadystatechange = function () {
if (httpRequest.readyState == 4) {
// access httpRequest.responseXML here
}
};
httpRequest.open('GET', 'file.xml', true);
httpRequest.send(null);


--

Martin Honnen
http://JavaScript.FAQTs.com/

0 new messages