Achref_h
14 years agoNew Contributor
Validate against XSD
Hi,
I would like to validate xml file with xsd using TC script, but it seemsit checks only syntax. how i should modify this script to validate with shema.
function Validate(xmlFile,xsdFile)
{
var xmlDoc = Sys["OleObject"]("Msxml2.DOMDocument.6.0");
var cache = Sys["OleObject"]("Msxml2.XMLSchemaCache.6.0");
xmlDoc.async = false;
xmlDoc.validateOnParse = false;
cache["add"]("",xsdFile);
xmlDoc["schemas"] = cache;
xmlDoc.load(xmlFile);
if (xmlDoc.parseError.errorCode != 0)
{
var myErr = xmlDoc.parseError;
Log.Error("You have error " + myErr.reason);
}
else
{
Log.Message(xmlDoc.xml) ;
}
}
I would like to validate xml file with xsd using TC script, but it seemsit checks only syntax. how i should modify this script to validate with shema.
function Validate(xmlFile,xsdFile)
{
var xmlDoc = Sys["OleObject"]("Msxml2.DOMDocument.6.0");
var cache = Sys["OleObject"]("Msxml2.XMLSchemaCache.6.0");
xmlDoc.async = false;
xmlDoc.validateOnParse = false;
cache["add"]("",xsdFile);
xmlDoc["schemas"] = cache;
xmlDoc.load(xmlFile);
if (xmlDoc.parseError.errorCode != 0)
{
var myErr = xmlDoc.parseError;
Log.Error("You have error " + myErr.reason);
}
else
{
Log.Message(xmlDoc.xml) ;
}
}