Howdy, folks!
I'll check in with Nicholas and see if he's still supporting the zXml library. If not, I'll update it a bit as time allows in the next few days. In the meantime, you can use an XMLHttpRequest object to grab the XML file and parse it with loadXML(), like this:
Code:
function init() {
var oXmlDom = zXmlDom.createDocument();
var oReq = zXmlHttp.createRequest();
oReq.onreadystatechange = function() {
if (oReq.readyState == 4) {
oXmlDom.loadXML(oReq.responseText);
parseBookInfo(oXmlDom);
}
};
oReq.open("GET", "books.xml", true);
oReq.send(null);
// var oXmlDom = zXmlDom.createDocument();
// oXmlDom.onreadystatechange = function () {
// if (oXmlDom.readyState == 4) {
// if (oXmlDom.parseError.errorCode == 0) {
// parseBookInfo(oXmlDom);
// } else {
// var str = "An error occurred!!\n" +
// "Description: " + oXmlDom.parseError.reason + "\n" +
// "File: " + oXmlDom.parseError.url + "\n" +
// "Line: " + oXmlDom.parseError.line + "\n" +
// "Line Position: " + oXmlDom.parseError.linepos + "\n" +
// "Source Code: " + oXmlDom.parseError.srcText;
// alert(str);
// }
// }
// };
// oXmlDom.load("books.xml");
}
It isn't perfect by any stretch of the imagination, but it works. Note that since this code uses XMLHttpRequest, the page has to be served from a web server or it will not work.