I'm using an xmlreader to read an xml file. The problem is i have many undefined namespaces in the child elements. Because of it, I'm unable to read the content of the files. Is there any way to read the contents of the files avoiding this issue or is there any solution to handle these kind of scenarios?
You can add the missing namespaces to the XmlReader like this.
var settings = new XmlReaderSettings
{
NameTable = new NameTable(),
};
XmlNamespaceManager xmlns = new XmlNamespaceManager(settings.NameTable);
xmlns.AddNamespace("yourundeclarednamespace", "http://www.dummynamespace.org");
XmlParserContext context = new XmlParserContext(null, xmlns, "", XmlSpace.Default);
using (var reader = XmlReader.Create(filePath, settings, context))
{
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With