I am using C# in my project. I have a long XML file. I want to import all of them at once in a CSV file. I am trying this by writing the following code, But there is mismatch inside column. Next column value comes previously. Suddenly I noticed that for some attributes (For example Note), the text is written with semicolon instead of Comman and as a result this text set in three columns instead of one.
Example "Review VAT query; draft simple VAT agreement; review law and reply to queries".How can I ingore Semicolon of that properties.
Here is my code.
var output = new StringBuilder();
output.AppendLine("EmployeeId;EmployeeFirstName;EmployeeLastName;AllocationId;TaskId;TaskName;ProjectName;CustomerName;InvoiceAmount;WorkHours");
if (workUnit != null)
{
foreach (XmlNode customer in workUnit)
{
var unit = new WorkUnit();
var childNodes = customer.SelectNodes("./*");
if (childNodes != null)
{
for (int i = 0; i < childNodes.Count; ++i)
{
XmlNode childNode = childNodes[i];
output.Append(childNode.InnerText);
if (i < childNodes.Count - 1)
output.Append(";");
}
}
output.Append(Environment.NewLine);
}
Console.WriteLine(output.ToString());
File.AppendAllText("c:\\..WorkUnits.csv", output.ToString());
}