0

I am getting that exception('Chart:' undeclared namespace) on executing the code

xmlString =" <Chart:Bullet values='100,200' size='100x20' shading='5' >";
     
      XmlDocument doc = new System.Xml.XmlDocument();
      
      doc.LoadXml(xmlString);
2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by hielo
0

Try:

xmlString ="<Chart:Bullet xmlns:Chart='http://yoursite.com' values='100,200' size='100x20' shading='5' ></Chart:Bullet>";

XmlDocument doc = new System.Xml.XmlDocument();
      
doc.LoadXml(xmlString);

//Instantiate an XmlNamespaceManager object. 
System.Xml.XmlNamespaceManager xmlnsManager = new System.Xml.XmlNamespaceManager(xmldoc.NameTable);

//Add the namespaces used in books.xml to the XmlNamespaceManager.
xmlnsManager.AddNamespace("Chart", "http://yoursite.com");

Additionally, the following resources may be of interest to you:
http://support.microsoft.com/kb/318545
http://stackoverflow.com/questions/331568/how-do-i-add-multiple-namespaces-to-the-root-element-with-xmldocument
http://stackoverflow.com/questions/310669/why-does-c-xmldocument-loadxmlstring-fail-when-an-xml-header-is-included

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.