留着备用
public void Transfer(string inXmlFilename, string outCSVFilename)
{
// open or create
FileStream fileCsv = new FileStream(outCSVFilename,FileMode.OpenOrCreate,FileAccess.Write);
StreamWriter writerCsv = new StreamWriter(fileCsv);
StreamReader readerXml=new StreamReader(inXmlFilename);
XmlDataDocument datadoc = new XmlDataDocument();
datadoc.DataSet.ReadXml(readerXml);
// read each test case, write to CSV file
for (int i= 0; i < datadoc.ChildNodes[0].ChildNodes.Count; i++)
{
string strCsvLine = "";
for (int j=0; j < datadoc.ChildNodes[0].ChildNodes[i].ChildNodes.Count; j++)
{
string strText = datadoc.ChildNodes[0].ChildNodes[i].ChildNodes[j].InnerText;
strCsvLine += strText.Replace(",", ".") + ",";
}
writerCsv.WriteLine(strCsvLine);
}
readerXml.Close();
writerCsv.Close();
}