我有一个XML文档,看起来像难度使用LINQ
<Settings>
<Config>
<type>stuff</type>
<length>stuff</length>
<ID>1</ID>
</Config>
</Settings>
我试图将其追加使用
Document loadedDoc = XDocument.Load (file);
loadedDoc.Element("Settings").Add(new XElement("Config"),
new XElement("type", "stuff"),
new XElement("length", "stuff"),
new XElement("ID", "2"));
loadedDoc.Save(file);
什么我收到的时候我这样做是
追加到XML文件<Settings>
//the other configs hidden for readability
<Config /> <--- WHAT DO?! 0_o
<type>stuff</type>
<length>stuff</length>
<ID>2</ID>
</Settings>
有人能更好地熟练linq告诉我它是什么我做错了,使它创建一个空配置eleme nt那样?谢谢!
这个伎俩!谢谢! – user1548103 2013-05-06 15:38:55