Results 1 to 2 of 2

Thread: Javascript & XML...converting an XML file into a string

  1. #1
    Join Date
    Dec 2009

    Javascript & XML...converting an XML file into a string

    Working through the Javascript book "Professional Javascript for Web Developers" by Wrox, author "Zakas".
    In particular I am working through his section on how to handle XML processing in Javascript.

    The author gives a really good function to handle converting an XML string into a DOM object for processing,
    but the book stops short on suggesting a way to handle files. Now I can handle files in two of the three cases
    xmldom.load('myfile.xml') for IE &
    //The DOM 3 Load and Save ..works in Opera.. 
    var parser = document.implementation.createLSParser(document.implementation.MODE_SYNCHRONOUS, null);
    //add event listener to determine when document has loaded
    //code here...however...the load event never fires in 9.5..So I need to address this problem also
    So the question is how do I convert an XML file to a string if my browser is using DOMParser?
    Because this method will only take a string:
    var parser = new DOMParser();
    var xmldom = parser.parseFromString("<root><child/></root>", "text/xml");
    // as you can see the above code only takes a string, no other options here.

    thanx kevin

  2. #2
    Join Date
    Dec 2003
    Bucharest, ROMANIA
    But why to convert an XML object into a string?

    There is a strong reason for using XML (or JSON): to structure the transferred information/data. If you make the effort to order the data as an XML object, why to dismantle it back to an amorphous string?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center