using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Xml.Linq;

namespace XMLSave
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void btnQuit_Click(object sender, EventArgs e)
        {
            // End the application.
            Close();
        }

        private void btnSave_Click(object sender, EventArgs e)
        {
            // Build the XML document.
            XDocument NewDoc = new XDocument(
                new XDeclaration("1.0", "utf-8", "yes"),
                new XElement("sample",
                    new XElement("data", "Hello"),
                    new XElement("data", "Goodbye")));

            // Save the document to the hard drive.
            NewDoc.Save(
                Environment.GetFolderPath(
                    Environment.SpecialFolder.DesktopDirectory) + 
                "\\XMLSave.XML");

            // Display a success message.
            MessageBox.Show("File saved!");
        }
    }
}
