My XML file.
Below is the code I am using to export my XML file to a CSV file. I can export the text MOISTURE, DOCKAGE, GRADE DISCOUNT etc. to column A. But I want to export the numerical values for these fields 14.5, 10.0, 0.0 etc. I don't know how to get one level deeper in the tree. Help?
Below is the code I am using to export my XML file to a CSV file. I can export the text MOISTURE, DOCKAGE, GRADE DISCOUNT etc. to column A. But I want to export the numerical values for these fields 14.5, 10.0, 0.0 etc. I don't know how to get one level deeper in the tree. Help?
C#:
namespace ConvertXML
{
class Program
{
static void Main()
{
StringBuilder result = new StringBuilder();
foreach (XElement level1Element in XElement.Load(@"C:\scaletickets.xml").Descendants("discount"))
{
result.Append(level1Element.Attribute("description").Value + "\r\n" );
}
StreamWriter sw = new StreamWriter(@"C:\Result.csv");
sw.WriteLine(result.ToString());
sw.Close();
}
}
}
Attachments
Last edited by a moderator: