How to add an existing Xml string into a XElement?
This code
var doc = new XDocument(
new XElement(\"results\", \".
See my answer on Is there an XElement equivalent to XmlWriter.WriteRaw?
Essentially, replace a placeholder for the content only if you know it's already valid XML.
var d = new XElement(root, XML_PLACEHOLDER);
var s = d.ToString().Replace(XML_PLACEHOLDER, child);
This method may also be faster than parsing it with XElement.Parse
.