Validating XML on XSD with the error line numbers

前端 未结 6 1045
盖世英雄少女心
盖世英雄少女心 2021-01-04 15:19

Is there any way to validate an XML file on an XSD schema with the output of the error line numbers?

The XmlReader reader doesn\'t allow line numbers, it shows only

6条回答
  •  悲哀的现实
    2021-01-04 15:40

    See the original MSDN example:

    http://msdn.microsoft.com/en-us/library/ms172454.aspx

    ValidationEventHandler's ValidationEventArgs argument has Exception.LineNumber:

    private void SchemaValidationEventHandler(object sender, ValidationEventArgs e) {
        Console.WriteLine("XML {0}: {1} (Line {2})",
                             e.Severity,
                             e.Message,
                             e.Exception.LineNumber);
    }
    

提交回复
热议问题