Feeds:
Posts
Comments

Posts Tagged ‘XSD’

C# Schema Validator

Can be wrapped into a reusable function for easy reuse

//The C# validator
//———————                   
System.Xml.XmlDocument objWorkingXML = new XmlDocument();
System.Xml.XmlValidatingReader objValidateXML;
System.Xml.Schema.XmlSchemaCollection objSchemasColl = new XmlSchemaCollection();

System.Xml.XmlTextReader xmlTxtReader = new System.Xml.XmlTextReader(@”..\..\rss.xsd”);

objSchemasColl.Add(“urn:simeon.com/xmlschemas/dosvis/dosvisgrouppayauthority/”, xmlTxtReader);
//This loads XML string in.. but you can also load files similarly
objValidateXML = new System.Xml.XmlValidatingReader(new XmlTextReader(@”..\..\rss.xml”));

//This is how you CATCH the errors (with a handler function)
//AddHandler objValidateXML.ValidationEventHandler, AddressOf [...]

Read Full Post »