XmlDocument doc = new XmlDocument();
doc.AppendChild(doc.CreateElement("Foo"));
doc.DocumentElement.InnerXml = "Test";
StringBuilder result = new StringBuilder();
doc.WriteContentTo(XmlWriter.Create(result));
At the end, result is:
<Foo>Test
that means the end element is missing. Why is that and how can I fix it?