次のようなXMLドキュメントがあります
<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);
これを行うときに得られるのは
<Settings>
//the other configs hidden for readability
<Config /> <--- WHAT DO?! 0_o
<type>stuff</type>
<length>stuff</length>
<ID>2</ID>
</Settings>
linq に精通した誰かが、そのような空の構成要素を作成するために私が間違っていることを教えてもらえますか? ありがとう!