How to save an xml-string into an Xml document

Platform: ASP.NET|Category: XML

VB.NET

Dim xmlText As String = '<?xml version=''1.0''?><root><node>Node1</node><node>Node2</node></root>'
Dim xmlDoc As New XmlDocument
xmlDoc.LoadXml(xmlText)
Dim writer As XmlTextWriter = New XmlTextWriter(Server.MapPath('data.xml'), Nothing)
writer.Formatting = Formatting.Indented
xmlDoc.Save(writer)

C#

string xmlText = '<?xml version=\'1.0\'?><root><node>Node1</node><node>Node2</node></root>';
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml(xmlText);
XmlTextWriter writer = new XmlTextWriter(Server.MapPath('data.xml'),null);
writer.Formatting = Formatting.Indented;
xmlDoc.Save(writer);