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
using:
Code:
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
parser.parseURI('example.xml');
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:
Code:
var parser = new DOMParser();
var xmldom = parser.parseFromString("<root><child/></root>", "text/xml");
// as you can see the above code only take a string, no other options here.
I was thinking that I could do a file read and use the string buffer function found in the beginning Javascript book. Is there a better way?
thanx kevin