I want to use a XmlTextReader that ignores Namespaces and does not check characters. To ignore namespaces I can set the property Namespaces=false and to not check characters I can use the XmlReaderSettings.CheckCharacters = false.
I tried to create the XmlTextReader using it constructors, but that does not allow me to pass in a configured XmlReaderSettings. The property Settings is readonly so that I cannot set it after construction.
XmlTextReader reader = new XmlTextReader(gzs) { Namespaces = false};
reader.Settings = new XmlReaderSettings { CheckCharacters = false}; // readonly
Using the static method Create() of the base class XmlReader I can pass in the XmlReaderSettings, but the method returns a XmlTextReaderImpl and that has no property Namespace to set and it cannot be cast to XmlTextReader.
var settings = new XmlReaderSettings { CheckCharacters = false};
var reader = XmlTextReader.Create(gzs, settings);
XmlTextReader textReader = reader as XmlTextReader // not possible
So how do I create such a XmlTextReader? Is it even possible? Are there any properties on XmlReaderSettings to ignore namespaces?