Q:

XmlAttribute value and innertext

I have a piece of code that fills a hashtable with strings, per example: ("name", Oscar). I want to use them to fill (just by memory usage) values and innertexts of XMLAtributes. But there is one problem.
XmlElement Co = newDoc.CreateElement("Co1");

 XmlAttribute series = Co.Attributes.Append(newDoc.CreateAttribute("series"));
         series.InnerText = (string)vector["series"];
         series.Value = (string)vector["series"];
         MessageBox.Show((string)vector["series"]);
         MessageBox.Show(Co.Attributes["series"].InnerText.ToString());
         MessageBox.Show(Co.Attributes["series"].Value.ToString());

When ever I want the system to show me the value or the innertext (within the xml create method this piece of code is in) it has it returns nothing. Then It passes to the next atribute and returns a  "Object reference not set to an instance of an object.". The next piece of code is this one:
XmlAttribute folio = Co.Attributes.Append(newDoc.CreateAttribute("folio"));
             folio.InnerText = vector["folio"].ToString();

The error hits in the last line.
In any other place of the class I can see  and retrieve the values of the hastable by the .ToString() method and the cast.
It seems that Im not properly getting the value out of my hashtable or there is something I am missing with the XMLAtributes... ¿What is the proper way to do so?

A:

You are doing this the hard way:
var folio = Convert.ToString(vector["folio"]);
Co.SetAttribute("folio", folio);

There is no need to worry about things like InnerText.

