[Mono-dev] Adding namespaces to an XmlDocument not working

Hiawatha imaudi at comcast.net
Fri Mar 13 19:58:38 EDT 2009

Hi guys..  I have the following code that works perfectly on .NET:

         string xml = "<Foo><Dynamic:bar>123</Dynamic:bar></Foo>";

         XmlDocument doc = new XmlDocument();
         NameTable nt = new NameTable();
         XmlNamespaceManager nsmgr = new XmlNamespaceManager(nt);
         nsmgr.AddNamespace("Dynamic", "urn:Test");

         XmlParserContext parserContext = new XmlParserContext(null, nsmgr,
null, XmlSpace.Default);
         XmlReader reader = XmlReader.Create(new StringReader(xml), null,

         Console.WriteLine("Results:\n" + doc.DocumentElement.OuterXml);

However, if I run it under Mono I get the exception:

Unhandled Exception: System.Xml.XmlException: 'Dynamic' is undeclared
namespace.  Line 1, position 19.

Any ideas on why this is?  Is this a known bug, or is there somewhere I can
log it?  Thanks!!

View this message in context: http://www.nabble.com/Adding-namespaces-to-an-XmlDocument-not-working-tp22507321p22507321.html
Sent from the Mono - Dev mailing list archive at Nabble.com.

More information about the Mono-devel-list mailing list