Q: Mozilla, XML and JavaScript

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • JF

    Q: Mozilla, XML and JavaScript

    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

  • Martin Honnen

    #2
    Re: Q: Mozilla, XML and JavaScript



    JF wrote:
    [color=blue]
    > 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.[/color]

    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.ope n('GET', 'test20031204.x ml', true);
    httpRequest.onr eadystatechange = function (evt) {
    if (httpRequest.re adyState == 4) {
    var xmlDocument = httpRequest.res ponseXML;
    alert(xmlDocume nt.getElementsB yTagName('*').l ength);
    }
    }
    httpRequest.sen d(null);

    The XML file at the URL test20031204.xm l 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


    Comment

    • DB McGee

      #3
      Re: Mozilla, XML and JavaScript

      "JF" <jfeit@ics.muni .cz> wrote in message news:HpDHFD.1xL @news.muni.cz.. .[color=blue]
      > 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[/color]


      Some useful links:

      JavaScript is a programming language that is primarily used to create interactive and dynamic website content. It can be used to manipulate the Document Object Model (DOM) in a web page, making it a popular choice for creating dynamic user interfaces and web applications.

      Founded in 1997, DEVShed is the perfect place for web developers to learn, share their work, and build upon the ideas of others.



      Comment

      Working...