convert xml string to file c# code example
Example 1: string to xml c#
string test = "<body><head>test header</head></body>";
XmlDocument xmltest = new XmlDocument();
xmltest.LoadXml(test);
XmlNodeList elemlist = xmltest.GetElementsByTagName("head");
string result = elemlist[0].InnerXml;
//result -> "test header"
Example 2: convert xml string to file c#
File.WriteAllText("foo.xml", xml);