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 = (headers[0] as List<string>)[i];
headname.Replace("&", "&");
headname.Replace("<", "<");
headname.Replace(">", ">");
headname.Replace("\"", """);
headname.Replace("'", "'");
textWriter.WriteStartElement("MetadataName", "");
textWriter.WriteString(headname);
textWriter.WriteEndElement();
The problem I'm having is that after it goes through the for loop once, i get a 'Token StartElement in state Epilog would result in an invalid XML document' error on the line with WriteStartElement, and I've tried looking up how to fix it and have not really had any breakthroughs. Thanks.
EDITED for update.