我正在撰写Function
以将新Nodes
添加到XML
文件,因此我创建了2 List<string>
,然后将它们合并为以下
var FirstText = FirstList;
var SecondText = SecondList;
var AllText = FirstText.Zip(SecondText, (t1, t2) => new { FirstWord = t1, SecondWord = t2 });
foreach (var tt in AllText)
{
Xml.WriteStartElement(tt.FirstWord);
Xml.WriteValue(tt.SecondWord);
Xml.WriteEndElement();
}
添加类似这样的内容
<Force>True</Force>
<Auto>False</Auto>
现在我想通过写这个
来组合3strings
而不是2
Xml.WriteStartElement(tt.FirstWord);
Xml.WriteStartElement(tt.SecondWord);
Xml.WriteValue(tt.ThirdWord);
Xml.WriteEndElement();
Xml.WriteEndElement();
所以XML
看起来像
<Settings>
<Force>True</Force>
</Settings>
<Settings>
<Auto>True</Auto>
</Settings>
我该怎么做?
答案 0 :(得分:3)
再次致电.Zip
:
var AllText = FirstText.Zip(SecondText, (t1, t2) => new { FirstWord = t1, SecondWord = t2 });
.Zip(Values, (t12, v) => new
{ FirstWord = t12.FirstWord,
SecondWord = t12.SecondWord,
ThirdWord = v });
你也可以