从XElements列表中创建XDocument

时间:2015-12-14 18:52:07

标签: c# xml

我正在寻找一个从XDocument列表中创建XElements的解决方案。

List<XElement> result;
XDocument resultDocument = //to be created from result

我怎样才能做到这一点?

1 个答案:

答案 0 :(得分:2)

您可以通过将XDocument嵌入根标记中来XElement创建XDocument xmlDoc= new XDocument( new XElement("Root", new XElement("Child1", "result1"), new XElement("Child2", "result2"), new XElement("Child3", "result3") ) ); ,请参阅下面的代码段:

List<XElement> result

或如果您有XDocument xmlDoc= new XDocument( new XElement("Root", result ) ); ,则可以执行以下操作:#

default_working_project_id
相关问题