I\'m trying to write to an XML document, taking data from an ArrayList of lists
for (int i = 0; i < 15; i++)
{
string headname
Your problem is here:
textWriter.WriteStartElement("Metadata Name", "");
An element name cannot contain spaces. Try this:
textWriter.WriteStartElement("MetadataName", "");
I am assuming that the data in your headers array is well formed for XML (for example, all & are escaped to & etc...).
Additionally, as Mark notes in his answer, you need to make sure the XML is rooted - that is, that there is a root element in which you put your MetadataName elements.
Read about well formed XML and what that means - you need to make sure your document is well formed, as you build it up.