var xs, xd; main(); function main() { try { xd = new ActiveXObject("MSXML2.DOMDocument.5.0"); } catch (e) { alert("Mirosoft XML Core Services (MSXML) 5.0 for Microsoft Office is not installed.\n" +"Download and install MSXML 5.0 from http://msdn.microsoft.com/xml\n" +"before continuing."); return; } try { xd.async = false; xd.validateOnParse = false; xd.load("books.xml"); xd.setProperty("MultipleErrorMessages", true); } catch (e) { alert("can't load books.xml : " + e.description); return; } // Validate the XML document, relying on the xsi:schemaLocation // attribute of the document element to resolve where to read the // schema definition. var err = xd.validate(); if (err.errorCode != 0 ) { var allErrs = err.allErrors; var str=""; i = 0 while (null != (e=allErrs.next)) { str += ("errorItem["+ i++ +"]: "+e.reason+"\n"); } alert(str); } else alert("valid dom as follows:\n" + xd.xml); } function alert(msg) { WScript.echo(msg); }
Try It!
Note Under operating systems other than Windows 2000 or Windows XP, you might need to install Windows Scripting Host (wscript.exe), if it is not already installed.