繁体   English   中英

使用Xsd验证Xml并更新Xml

[英]Validate Xml with Xsd and update Xml

我正在使用现有Xsd架构验证Xml文件。 如果验证失败,是否可以使用xsd文件更新Xml?

错误后,您可以执行此代码

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);  
} 

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

暂无
暂无

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

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