I need to save modified xml in xmlDocument to string variable. Surprisingly, there is no easy way to do it. This is what I found and working
System.IO.StringWriter sw = new System.IO.StringWriter();
System.Xml.XmlTextWriter tr = new System.Xml.XmlTextWriter(sw);
xDoc.WriteContentTo(tr);
string xmlstring = sw.ToString();
tr.Close();
sw.Close();
System.Xml.XmlTextWriter tr = new System.Xml.XmlTextWriter(sw);
xDoc.WriteContentTo(tr);
string xmlstring = sw.ToString();
tr.Close();
sw.Close();
xDoc is my xml document.