XmlDocument doc = new XmlDocument();
doc.Load("filename.xml");
doc.DocumentElement.RemoveAll();
string result = doc.OuterXml;
But if you know the root name of the node, it makes no sense to load the XML and delete all the elements. In this case, just return the new XML:
string newXml = "<rootName/>";
source
share