Below is the function to validate the XML's. This function will return 'true' if it is a valid XML, else will return 'false'.
----------------------------------------------------------------
----------------------------------------------------------------
var msgError = "", isValidNode = 1; function checkErrorXML(xml) { msgError = ""; isValidNode = 1; checkXML(xml); } function checkXML(node) { var l, i, nam; nam = node.nodeName; if (nam == "h3") { if (isValidNode == 0) { return; } isValidNode = 0; } if (nam == "#text") { msgError = msgError + node.nodeValue + "\n"; } l = node.childNodes.length; for (i = 0; i < l; i++) { checkXML(node.childNodes[i]); } } function validateXML(inputXml) { var returnFlag = true; // Validate in IE if (window.ActiveXObject) { var xmlDoc = new ActiveXObject("Microsoft.XMLDOM"); xmlDoc.async = false; xmlDoc.loadXML(document.all(inputXml).value); if (xmlDoc.parseError.errorCode != 0) { returnFlag = false; } else { returnFlag = true; } } // Validate in Mozilla, Firefox, Opera, etc. else if (document.implementation.createDocument) { var parser = new DOMParser(); var text = document.getElementById(inputXml).value; var xmlDoc = parser.parseFromString(text, "text/xml"); if (xmlDoc.getElementsByTagName("parsererror").length > 0) { checkErrorXML(xmlDoc.getElementsByTagName("parsererror")[0]); returnFlag = false; } else { returnFlag = true; } } else { //No Browser Support returnFlag = false; } return returnFlag; }