More XmlValidatingReader

  • Thread starter Thread starter Peter Morris [Droopy eyes software]
  • Start date Start date
P

Peter Morris [Droopy eyes software]

Hi all

I used XmlValidatingReader in the full framework v1.1 - Now I need to do the
same thing in CF 2.0; basically I need to validate the XML as I read it in
line by line, my XSD is an embedded resource.

Can someone help me out please? I'm looking a bit lost here.

Thanks

Pete
 
Thanks, I've come up with this....

FileStream xmlStream = new FileStream("\\DataImport.xml", FileMode.Open);

Stream xsdStream =
GetType().Assembly.GetManifestResourceStream("WindowsApplication1.DataImport.xsd");

XmlReader xsdReader = new XmlTextReader(xsdStream);

System.Xml.Schema.XmlSchema xsdSchema =
System.Xml.Schema.XmlSchema.Read(xsdReader, null);

XmlReaderSettings readerSettings = new XmlReaderSettings();

readerSettings.ValidationType = ValidationType.Schema;

readerSettings.Schemas.Add(xsdSchema);

readerSettings.ValidationEventHandler += new
System.Xml.Schema.ValidationEventHandler(readerSettings_ValidationEventHandler);

XmlReader xmlReader = XmlTextReader.Create(xmlStream, readerSettings);

while (xmlReader.Read())





Pete
 
Back
Top