XML Syntax validator that works with Mozilla

wxdqz

New Member
Hello,
I have a textarea called validxml in which the user can enter a xml document. WHen the user clicks the "Validate" button, the javascript function "validateXML() is executed.
The function works with IE but I can't make it work for Mozilla.
COuld someone help me, please?


function validateXML()
{
if (document.implementation && document.implementation.createDocument)
{
//Mozilla browsers
.........
}
else if (window.ActiveXObject) //IE browser
{
xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async = "false";
xmlDoc.loadXML(document.all("validxml").value);

if(xmlDoc.parseError.errorCode!=0)
{
txt="Error Code: " + xmlDoc.parseError.errorCode + "\n";
txt=txt+"Error Reason: " + xmlDoc.parseError.reason;
txt=txt+"Error Line: " + xmlDoc.parseError.line;
document.forms["rule"].validxml.focus();
alert(txt);
}
else
{
alert("No errors found");
}
}
}
 
Back
Top