using System; using System.Xml; using System.Xml.Schema; using System.IO; public class Sample { public static void Main() { XmlSchemaSet sc = new XmlSchemaSet(); sc.Add("", "books.xsd"); XmlReaderSettings settings = new XmlReaderSettings(); settings.ValidationType = ValidationType.Schema; settings.Schemas = sc; settings.ValidationEventHandler += new ValidationEventHandler (ValidationCallBack); XmlReader reader = XmlReader.Create("booksSchemaFail.xml", settings); while (reader.Read()); } private static void ValidationCallBack(object sender, ValidationEventArgs e) { Console.WriteLine("Validation Error: {0}", e.Message); } }
c# проверяем xml по xsd схеме
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment
Note: only a member of this blog may post a comment.