0

I am trying to load XML document to traverse, can someone please explain why does the below line does not work and a http request has to be made to load the XML document though the XML is stored in the same folder as the HTML.

 var xmlDoc = loadXMLDoc("filename.xml")

Thanks in advance.

1 Answers1

0

you need to read the file back from the server and then render the response. So i would suggest using ajax to do this, then using jQuery to parse the xml

$.ajax({
    type: "GET",
    url: "filename.xml",
    dataType: "xml",
    success: function (xml) {
        // Parse the xml file and get the data 
        // Do what you want here to find the elements in the xml
        var doc = $.parseXML(xml),
            $xml = $(xmlDoc);
    }
});
Josh Stevens
  • 3,943
  • 1
  • 15
  • 22