.NET and XML: How can I read nested namespaces (<abc:xyz:name attr="value"/>)?
- by Entrase
Suppose there is an element in XML data: <abc:xyz:name attr="value"/>
I'm trying to read it with XmlReader. The problem is that I get XmlException that says
The ‘:’ character, hexadecimal value 0x3A, cannot be included in a name
I have already declared "abc" namespace. I have also tried adding "abc:xyz" and "xyz" namespaces. But this doesn't help at all. I could replace some text before parsing but there may be some more elegant solution. So what should I do?
Here is my code:
XmlReaderSettings settings = new XmlReaderSettings()
NameTable nt = new NameTable();
XmlNamespaceManager nsmgr = new XmlNamespaceManager(nt);
nsmgr.AddNamespace("abc", "");
nsmgr.AddNamespace("xyz", "");
XmlParserContext context = new XmlParserContext(null, nsmgr, null, XmlSpace.None);
// So this reader can't read <abc:xyz:name attr="value"/>
XmlReader reader = XmlReader.Create(path, settings, context);“