On 27 Feb, 16:10, "JoeZ" <j...@microsoft.comwrote:
Hi all,
I am looking for some sample codes in C#, in which, it can read a schema xsd
file and use it to validate an xml stream or file. Ideally the sample will
use XmlValidatingReader.
TIA,
JoeZ
Try this:
FileStream fs = File.Open("../../signatureinstance.xml",
FileMode.Open);
XmlTextReader reader = new XmlTextReader(fs);
XmlValidatingReader xvr = new XmlValidatingReader(reader);
xvr.ValidationType = ValidationType.Schema;
xvr.Schemas.Add(null, "../../signatureschema.xsd");
xvr.ValidationEventHandler += new
ValidationEventHandler(xvr_ValidationEventHandler) ;
XmlDocument xdoc = new XmlDocument();
xdoc.Load(xvr);
Courtesy of:
http://www.codeproject.com/useritems/XmlValidation.asp
Or, you could try here:
http://support.microsoft.com/kb/318504