I want to parse 'invalid' xml using a streaming xml parser. I have two options
XmlReader.Create(...,
new XmlReaderSettings()
{
CheckCharacters = false,
ConformanceLevel = ConformanceLevel.Fragment,
ValidationFlags = System.Xml.Schema.XmlSchemaValidationFlags.None,
ValidationType = ValidationType.None
}))
Second example
new XmlTextReader(...) { Namespaces = false, Normalization = false })
The first is failing on unrecognized namespaces which are presented in the xml: '...' is an undeclared prefix.
The second is failing on invalid characters: XmlException: '', hexadecimal value 0x13, is an invalid character. Line ...
Is there an option to combine both behaviors (Namespaces = false
&& CheckCharacters = false
) so parsing will not fail on undefined namespaces and invalid characters?
Input "xml" cannot be changed as provided as is. It is also huge and cannot be loaded to the memory.
Update Xml example
<?xml version="1.0" encoding="UTF-8"?>
<x xmlns="http://www.w3.org/2005/Atom">
<item>
<my_ns:id>123 _0x13_here_ dd</my_ns:id>
<other_ns:value>ABC</other_ns:value>
</item>
</x>
Where _0x13_here_
is a (char)'\x13'
I was wrong, and using CheckCharacters = false
not helping here. It allows to avoid exceptions on content like 
only.