Validating XML on XSD with the error line numbers

前端 未结 6 1090
盖世英雄少女心
盖世英雄少女心 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 16:00

    Since @chris-watts suggested to post my comment again as answer. Here it is.

    The document only has line number information if it was loaded with the appropriate flags:

    var opts = LoadOptions.PreserveWhitespace 
             | LoadOptions.SetLineInfo;
    XDocument doc = XDocument.Load(fileStream, opts); 
    

提交回复
热议问题