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/