简体   繁体   English

使用Xsd验证Xml并更新Xml

[英]Validate Xml with Xsd and update Xml

i am validating a Xml file with an existing Xsd schema. 我正在使用现有Xsd架构验证Xml文件。 Is it possible to update the Xml with the xsd file if the validation fails? 如果验证失败,是否可以使用xsd文件更新Xml?

After Error you can execute this code 错误后,您可以执行此代码

var schemaSet = new XmlSchemaSet();  
schemaSet.Add(null, "schema1.xsd");  
// add further schemas as needed  
schemaSet.Compile();  

var xmlSampleGenerator= new XmlSampleGenerator(schemaSet, new XmlQualifiedName("Test"));  

var doc = new XmlDocument();  
using (XmlWriter writer = doc.CreateNavigator().AppendChild())  
{  
   xmlSampleGenerator.WriteXml(writer);  
} 

Link : http://msdn.microsoft.com/en-us/library/aa302296.aspx 链接: http//msdn.microsoft.com/en-us/library/aa302296.aspx

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM