//How to create xml file using c#.net asp.net code
//Append Node/ Modify Node in XML using c#.net asp.net
//
using System.Xml;
using System.IO;
protected void Button1_Click(object sender, EventArgs e)
{
string filepath = MapPath("xml/XMLFile3.xml"); // path of xml where we want to save it
create(filepath);
}
private void create(string filepath) // filepath is path where we want to save xml file
{
string xml = @"<?xml version='1.0' encoding='utf-8'?>
<ParentXMLNode>
<Header>
<xmlnode1>value1</xmlnode1>
<xmlnode2>value2</xmlnode2>
</Header>
<xmlnode3>value3</xmlnode3>
<xmlnode4>value4</xmlnode4>
<Message>
<xmlnode5></xmlnode5>
<xmlnode5></xmlnode5>
<xmlnode6>
<Node1></Node1>
</xmlnode6>
</Message>
</ParentXMLNode>";
XmlDocument docConfig = new XmlDocument();
docConfig.LoadXml(xml);
Literal1.Text = "<XMP>" + xml + "</XMP>";
docConfig.Save(filepath);
}