Level: Beginner You can use XmlValidatingReader class to validate an cml file against an XSD schema, Here is the code snippet to do it, XmlSchemaCollection schemaCol = new XmlSchemaCollection(); schemaCol.Add(“”,schemaFile); XmlTextReader textReader = null; XmlValidatingReader vReader = null; try { textReader = new XmlTextReader(xmlFile); // create a validating reader. vReader = new XmlValidatingReader(textReader); // validate using the schemas stored in the schema collection. vReader.Schemas.Add (schemaCol); // set the validation event handler vReader.ValidationEventHandler += new ValidationEventHandler(ValidationCallBack); …
3 articles Tag Xml
Access Denied Error with MSXML 4.0 SP2
Level: Advanced If you have recently updated your MSXML 4.0 with SP2 and started getting an “Access Denied” error, then read on… According to this Microsoft article, Security in the implementation of the MSXML 4.0 SP2 ServerXmlHttp object has been enhanced to check the Internet Explorer security policy setting for submitting non-encrypted form data. Follow these steps to configure IE Security, 1. Click Start, click Run, type mmc, and then press ENTER. 2. On the …
Creating DataSet from XML and XSD
Level: Beginner-Intermediate If you want to read your XML file into a DataSet, you could use the ReadXml method of the DataSet. You can read the XSD for the same XML file using ReadXMLSchema method. Here is how to use these methods, string doc = @”c:test.xml”;string docSchema = @”c:test.xsd”;XmlDataDocument myXmlDataDocument = new XmlDataDocument ; We will use a StreamReader to read the schema file, StreamReader reader = new StreamReader(docSchema);//this will read the schema to DataSetmyXmlDataDocument.DataSet.ReadXmlSchema(reader); …

Recent Comments