How to add an existing Xml string into a XElement
问题 How to add an existing Xml string into a XElement? This code var doc = new XDocument( new XElement("results", "<result>...</result>") ); of course produces this <results><result></result></results> but I need this <results><result>...</result></results> Any ideas? 回答1: This should work: var xmlString = "<result>sometext</result>"; var xDoc = new XDocument(new XElement("results", XElement.Parse(xmlString))); 回答2: The answer by Sani Singh Huttunen put me on the right track, but it only allows