By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,567 Members | 1,185 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,567 IT Pros & Developers. It's quick & easy.

Q: Mozilla, XML and JavaScript

P: n/a
JF
Hi,

can somebody give me a minimal example of how to read xml
file into mozilla AND run some Javascript funcion?

Mozilla can read xml files directly and css files can
be included as well, that works for me.
But I would like to do some operations with the DOM tree.

My question is Mozilla only, I would apperciate some
minimal example (like alert(1)) and especially some
URL pointers.

Thanks,
Josef

Jul 20 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a


JF wrote:
can somebody give me a minimal example of how to read xml
file into mozilla AND run some Javascript funcion?

Mozilla can read xml files directly and css files can
be included as well, that works for me.
But I would like to do some operations with the DOM tree.

My question is Mozilla only, I would apperciate some
minimal example (like alert(1)) and especially some
URL pointers.


Mozilla implements the XMLHttpRequest object that implements the same
interface that Msxml2.XMLHTTP implements, so an example to load an XML
file is

var httpRequest = new XMLHttpRequest();
httpRequest.open('GET', 'test20031204.xml', true);
httpRequest.onreadystatechange = function (evt) {
if (httpRequest.readyState == 4) {
var xmlDocument = httpRequest.responseXML;
alert(xmlDocument.getElementsByTagName('*').length );
}
}
httpRequest.send(null);

The XML file at the URL test20031204.xml is loaded asynchronously, on
readyState of the request object is 4 you can access the responseXML
object which is W3C DOM Level 2 document you can script. The example
simply counts the elements in the document.

See also the XML section on http://javascript.faqts.com/
--

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

Jul 20 '05 #2

P: n/a
"JF" <jf***@ics.muni.cz> wrote in message news:Hp********@news.muni.cz...
Hi,

can somebody give me a minimal example of how to read xml
file into mozilla AND run some Javascript funcion?

Mozilla can read xml files directly and css files can
be included as well, that works for me.
But I would like to do some operations with the DOM tree.

My question is Mozilla only, I would apperciate some
minimal example (like alert(1)) and especially some
URL pointers.

Thanks,
Josef

Some useful links:

http://www.webreference.com/programm...per/index.html
http://forums.devshed.com/t51667/s.html
Jul 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.