2

I am trying to create utility which accepts XML file and reports format (XML 1.0 syntax) errors if there is any. I tried these APIs XmlDocument.Load, XDocument.Parse, XmlReader.Read, These APIs throw exceptions at point where there is format error.

XML file can have format errors at multiple places, If I go with above APIs, I need to solve all format errors one by one. I would like to have error report as like as Visual Studio XML Editor. Visual studio list down all format errors in the ErrorList tab. Is there any solution?

Thanks in Advance

Manikandan
  • 673
  • 3
  • 12
  • 26
  • XmlReader has a setting parameter which you can turn off the error checks so you can do your own checking. – jdweng Apr 19 '17 at 09:50
  • 1
    there is no such parameter. only for schema validation. – Alexey Obukhov Apr 19 '17 at 09:59
  • 1
    @jdweng I agree with Alexey Obukhov. XmlReaderSettings doesn't help to solve this problem. – Manikandan Apr 19 '17 at 10:20
  • What about : settings.DtdProcessing = DtdProcessing.Ignore settings.IgnoreProcessingInstructions = True settings.CheckCharacters = False settings.ValidationFlags = Schema.XmlSchemaValidationFlags.None settings.ValidationType = ValidationType.None – jdweng Apr 19 '17 at 10:49
  • 1
    @jdweng with your suggested settings, XmlReader.Read() method throws exception at first occurrence of format error. – Manikandan Apr 19 '17 at 11:10
  • I think you have a solution here: http://stackoverflow.com/questions/35934789/c-catch-multiple-errors-during-xml-validation#35936551 – Arnaud Develay Apr 19 '17 at 13:26
  • Thanks @ArnaudDevelay This solution validates xml file against XML scheme. I don't want to validate xml against schema just to check xml formation. – Manikandan Apr 20 '17 at 06:33

0 Answers0