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);

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.