I have a string and its value is:
qwerty adsf The text of the samp
Try this:
string s = ""; XmlDocument xdoc = new XmlDocument(); xdoc.LoadXml(s); xdoc.Save("myfilename.xml");
Has the added benefit that the load will fail if your XML is invalid.