i build a application for validating xml file against XSd. if error occours in one node it throws a exception, in that exception i can get only line number and line position only. how to get the maxlength value of that node.
MemoryStream xml = new MemoryStream();
string xsd;
XmlReaderSettings settings = new XmlReaderSettings();
settings.ValidationType = ValidationType.Schema;
settings.Schemas.Add("", Application.StartupPath + "\\std_imaging.xsd");
settings.ValidationEventHandler += MyValidationEventHandler;
var v = XmlReader.Create(filename, settings);
while (v.Read())
{
string a1 = v.ValueType.Name.Length.ToString();
string name = v.NodeType + v.Name + v.ValueType + v.Value.ToString();
}
public void MyValidationEventHandler(object sender, ValidationEventArgs args)
{
schemaResult = false;
textBox1.Text = textBox1.Text + (Environment.NewLine + args.Message +
Environment.NewLine + "Location(" + args.Exception.LineNumber +
"," + args.Exception.LinePosition + ")" + Environment.NewLine);
}
this is my code.