Error Resistant XML Reader

Does anyone have / make / sell error-resistant XML reader for .NET?

Yes, I know, XML is not intended for errors in it and should be rejected if it is invalid .. blah blah. But, unfortunately, the real world is imperfect, and the developers make mistakes, and I still want to be able to read their channels, even if I skip the odd element here or there because it was not encoded properly or had some other error in it, So, please, no answers “fix the source” or “reject”.

So, does anyone have a component that can repair and handle common errors in XML files?

+4
source share
5 answers

Take a look around HTML Parser, because html is almost xml

+3
source

This is precisely because the real world is imperfect, because XML is so widely used. What will be the functional specification for error tolerant XML parsing? This is an open problem. It is difficult enough to parse all variants of well-formed XML without trying to repeat all possible errors.

[... Awaiting lowering down.]

+14
source

First run XML through Beautiful Soup . This will clear your XML errors so that it is parsed correctly.

+3
source

For a specific case of an RSS feed and a specific case of individual records of damaged positions, you can use the XmlTextReader to manually read each element separately, handling an XmlException for invalid elements. When an Exception occurs, you will need to use a new instance of Reader, since the original Reader will be closed. You still have to have valid <item> and </item> tags to identify each element, but you can recover corrupted data inside each element.

+2
source

yes, I know this old question, but recently I was looking for a tolerant xml parser and found the following: XmlParser .

A full-fledged Roslyn-based XML parser with no dependencies and a simple Visual Studio XML service.

The parser creates a syntax tree of complete accuracy, which means each character of the source text is represented in the tree. The tree covers the entire source text. The parser has no dependencies and can easily make it portable.

You can add Nugets to your project. I tried this parser and it can read any XML files.

+1
source

All Articles