当我使用WriteXML将DataSet转换为xml时更改xml结构?

时间:2014-07-23 18:21:50

标签: c# xml dataset writexml

以下内容将excel文件(一个工作表;一列)的内容放入需要为excel字符串的DataSet中:

enter image description here

        DataSet ds = excelReader.AsDataSet();

        StringWriter sw = new StringWriter();
        ds.WriteXml(sw);
        string result = sw.ToString(); 

它返回以下字符串:

<NewDataSet>
<Sheet2><Column1>70209429072734</Column1></Sheet2>
<Sheet2><Column1>30221442748624</Column1></Sheet2>
<Sheet2><Column1>70209433124464</Column1></Sheet2>
<Sheet2><Column1>30209434466634</Column1></Sheet2>
</NewDataSet>

我想要这种格式:

<DLN>
   <id>70209429072734</id>
   <id>30221442748624</id>
   <id>70209433124464</id>
   <id>30209434466634</id>
</DLN>

0 个答案:

没有答案