private const string filename = "output.xml";
/// <summary>
/// Create file code
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button1_Click(object sender, EventArgs e)
{
XmlTextWriter newXmlFile = new XmlTextWriter(filename,System.Text.Encoding.Default);
newXmlFile.WriteStartDocument();
newXmlFile.WriteStartElement("Begin","");
newXmlFile.WriteStartElement("One","");
newXmlFile.WriteFullEndElement();
newXmlFile.WriteEndElement();
newXmlFile.Flush();
newXmlFile.Close();
}
/// <summary>
/// Insert New code
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button2_Click(object sender, EventArgs e)
{
XmlDocument XMLDom = new XmlDocument();
XMLDom.Load(filename);
XmlNode newXMLNode = XMLDom.SelectSingleNode("Begin");
XmlNode childNode = XMLDom.CreateNode(XmlNodeType.Element,"One","");
XmlAttribute newAttribute = XMLDom.CreateAttribute("name","sree","");
childNode.Attributes.Append(newAttribute);
newXMLNode.AppendChild(childNode);
}
}
}