How to fix xml file based on xml schema?

There are many files that have been unintentionally modified, and now they do not correspond to their associated scheme.

What I want to do is find the errors and fix them automatically (if possible). I looked at the validation mechanism available in the .NET framework. The problem is that I do not know how I can edit an erroneous node. The validation event handler gives me an event argument that contains some information about the error itself, but not the node and the sender object, which is an object of type XmlValidationReaderImpl, of which I know nothing, and I could not find any information about this type anywhere .

Does anyone know how I can fix an Xml file using a validation mechanism or are there any other methods available?

+3
source share
1 answer

I’m not sure about using a validation mechanism, but if errors are simplified in form, you can always edit and correct them in raw text. You can do this using filestreams. If you want to study this, let me know. Maybe you can post some examples of how this looks and how it should look. I could write a function for you to fix this in no time.

+2
source

Source: https://habr.com/ru/post/1763300/


All Articles