【发布时间】:2019-10-31 10:31:46
【问题描述】:
我正在尝试创建一个转换器 CSV 到 XML。 XML 文件可能并不总是具有相同数量的字段,所以我试图获取这个数字,然后使用它来创建元素
string[] source = new string[] { ligne };
XElement element = new XElement("DOCUMENT",
new XElement("GED",
from li in source
let champs = ligne.Split(';')
select new XElement("INDEX",
// where i'd like to put the loop code
new XElement(col[0], champs[0]),
new XElement(col[1], champs[1]),
new XElement(col[2], champs[2])... //etc,
)
)
);
//the code i'd like to put in the previous code
for (int i = 0; i < col.Length +1; i ++)
{
new XElement(col[i], champs[i]);
},
【问题讨论】: