XML validation: Difference between revisions

Content added Content deleted
(Created page with "{{draft task}} Given an XML document and an XSD schema definition validate that the document follows the schema described. =={{header|C sharp}}== <lang csharp> using System...")
 
Line 16: Line 16:
// your code goes here
// your code goes here
XmlSchemaSet sc = new XmlSchemaSet();
XmlSchemaSet sc = new XmlSchemaSet();
sc.Add(null, "http://www.public.asu.edu/~jtrujil1/xml/Hotel.xsd");
sc.Add(null, "http://venus.eas.asu.edu/WSRepository/xml/Courses.xsd");
XmlReaderSettings settings = new XmlReaderSettings();
XmlReaderSettings settings = new XmlReaderSettings();
settings.ValidationType = ValidationType.Schema;
settings.ValidationType = ValidationType.Schema;
Line 22: Line 22:
settings.ValidationEventHandler += new ValidationEventHandler(ValidationCallBack);
settings.ValidationEventHandler += new ValidationEventHandler(ValidationCallBack);
// Create the XmlReader object.
// Create the XmlReader object.
XmlReader reader = XmlReader.Create("http://www.public.asu.edu/~jtrujil1/xml/Hotel.xml", settings);
XmlReader reader = XmlReader.Create("http://venus.eas.asu.edu/WSRepository/xml/Courses.xml", settings);
// Parse the file.
// Parse the file.
while (reader.Read());
while (reader.Read());