using System;
using System.IO;
using System.Xml;
using System.Xml.Schema;
using System.Collections.Generic;
using System.Text;
class Program
{
static void Main(string[] args)
{
XmlDocument items = new XmlDocument();
items.Load("items.xml");
XmlSchema schema = XmlSchema.Read(new FileStream("items.xsd",FileMode.Open), new ValidationEventHandler(OnSchemaValidate));
items.Schemas.Add(schema);
items.Validate(new ValidationEventHandler(OnValidate));
}
static void OnValidate(object sender, ValidationEventArgs vargs)
{
Console.WriteLine(vargs.Message);
}
static void OnSchemaValidate(object sender, ValidationEventArgs vargs)
{
Console.WriteLine(vargs.Message);
}
}
|