I am trying to create a listener page, that will validate and incoming XML document with an XSD.
When it hits XMLReader.Create is bombs out with the illegal character, but gives no indication where it is.
Has anyone had experience of create a listener and validating against a schema? This is using .NET 2.0 which differs slightly from 1.1 where you have to setup the XMLValidator class. in 2.0 you can lump everything intogether.. ( or so i keep reading!!)
thanks in advance
Code:
StreamReader InboundStream = new StreamReader(Page.Request.InputStream);
string UseString = InboundStream.ReadToEnd();
InboundStream.Close();
string result = ValidateXML(xmlString);
public string ValidateXML(string UseString)
{
try
{
XmlReader xmlrdr = XmlReader.Create(new StringReader(UseString));
xmlrdr.Settings.ValidationType = ValidationType.Schema;
xmlrdr.Settings.Schemas.Add(null, "Schemas\ttc1.xsd");
xmlrdr.Settings.ValidationEventHandler += new ValidationEventHandler(ValidationHandler);
while (xmlrdr.Read()) ;
return "Validated";
}
catch (Exception ex)
{
return ex.Message + "<br>" + ErrorsCount + "<br>" + ErrorMessage;
}
}
When it hits XMLReader.Create is bombs out with the illegal character, but gives no indication where it is.
Has anyone had experience of create a listener and validating against a schema? This is using .NET 2.0 which differs slightly from 1.1 where you have to setup the XMLValidator class. in 2.0 you can lump everything intogether.. ( or so i keep reading!!)
thanks in advance