Rawukal
Rawukal

Reputation: 65

Validate Xml with Xsd and update Xml

i am validating a Xml file with an existing Xsd schema. Is it possible to update the Xml with the xsd file if the validation fails?

Upvotes: 0

Views: 708

Answers (1)

Aghilas Yakoub
Aghilas Yakoub

Reputation: 28980

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

Upvotes: 1

Related Questions