Web Analytics Made Easy -
StatCounter retrieve data from xml using javascript - CodingForum

Announcement

Collapse
No announcement yet.

retrieve data from xml using javascript

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • retrieve data from xml using javascript

    i'm planning to create two pulldown menus. the first pulldown menu will display car makes such as toyota, ford, etc. this data is retrieved from an xml file. at this stage, the second pulldown menu will remain empty. when a person select toyota from the first pulldown menu, the second pulldown menu will automatically display the toyota models such as camry, corolla, prado, etc. this feature has to be dynamic. if the xml file is updated with a new toyota model, for eg, altis, then the second pulldown menu will be able to display the model altis as well.

    how could i do this? could anyone at least suggest some sites which could help me figure out how to create this feature?

    Thank you very much for your time and help.

  • #2
    Using the W3C DOM2 Core Recommendation createDocument method and the W3C DOM3 Load And Save Working Draft load method:

    var doc = document.implementation.createDocument('','',null);
    doc.addEventListener('load', someEventListener, false);
    doc.load('theuritothexmlfile.xml');

    And when the xml file is loaded, someEventListener(event) is fired.

    This is for Gecko-only at the moment (NS6, NS7, Mozilla, Beonex, K-meleon, Galeon, etc).

    IE supports its own, proprietary way with a well-publicized ActiveX object:

    var doc = new ActiveXObject('Microsoft.XMLDOM');
    doc.attachEvent('onreadystatechange', function() { if (event.target.readyState == 4) someEventListener() });
    doc.load('theuritothexmlfile.xml');

    Also, both browsers implement a proprietary XMLHttpRequest object:

    // in IE:
    var xmlhttp = new ActiveXObject('Msxml2.XMLHTTP');

    // in Gecko:
    var xmlhttp = new XMLHttpRequest();

    And once the object is defined, they both function
    accordingly to http://msdn.microsoft.com/library/de...ttprequest.asp
    In Gecko, all methods start with a lowercase letter, and some properties aren't implemented (i.e. use xmlhttp.send() and not xmlhttp.Send())
    jasonkarldavis.com

    Comment

    Working...
    X