Schema验证XML

前端之家收集整理的这篇文章主要介绍了Schema验证XML前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

private bool _validateXmlByXsd(string xmlFilePath){

string schemaFilePath = Path.GetFullPath(AWGWebService.Resources.release.G_ABN_ValidateXmlSchema);
XmlReaderSettings settings = new XmlReaderSettings();
settings.Schemas.Add(null,schemaFilePath);
settings.ValidationType = ValidationType.Schema;
settings.ValidationEventHandler += new System.Xml.Schema.ValidationEventHandler(settings_ValidationEventHandler);
XmlReader xmlReader = XmlReader.Create(xmlFilePath,settings);

while (xmlReader.Read())
{
if (xmlReader.NodeType == XmlNodeType.Text)
{
Console.WriteLine(xmlReader.Value);
}
}

xmlReader.Close();

return true;

}

原文链接:https://www.f2er.com/xml/296249.html

猜你在找的XML相关文章