I am writing an XML file, however when I go to read it it is all on the same line.
Can someone please look at my code and let know why its all appearing on the same line rather than in the correct format.
The code as you should see is writing a few nodes, then it is writing the code, name, formula, and so on... It's also checking that the formula from datarow 8 and beyond are not duplicates
var exportFile = "c:\\temp\\export.xml";
XmlWriter xmlWriter = XmlWriter.Create(exportFile);
xmlWriter.WriteStartDocument();
xmlWriter.WriteStartElement("designExport");
xmlWriter.WriteStartElement("designs");
xmlWriter.WriteStartElement("design");
foreach (DataRow dr in xltbl.Rows)
{
xmlWriter.WriteStartElement("code");
xmlWriter.WriteString(dr[0].ToString());
xmlWriter.WriteEndElement();
xmlWriter.WriteStartElement("name");
xmlWriter.WriteString(dr[1].ToString());
xmlWriter.WriteEndElement();
for (var i = 2; i < xltbl.Columns.Count; i++)
{
if (i >= 8 && dr[i] != dr[i - 8])
{
if (string.IsNullOrEmpty(dr[i].ToString())) continue;
xmlWriter.WriteStartElement("forumula");
xmlWriter.WriteString(dr[i].ToString());
xmlWriter.WriteEndElement();
xmlWriter.WriteStartElement("coverage");
xmlWriter.WriteString("0");
xmlWriter.WriteEndElement();
xmlWriter.WriteStartElement("usageFactor");
xmlWriter.WriteString("0");
xmlWriter.WriteEndElement();
}
}
}
xmlWriter.WriteEndDocument();
xmlWriter.Close();