namespace Import_and_Export_XML_File
{
public partial class Form1 : Form
{
DataSet ds = new DataSet();
public Form1()
{
InitializeComponent();
}
private void import_Click(object sender, EventArgs e)
{
OpenFileDialog openFileDialog1 = new OpenFileDialog();
openFileDialog1.Title = "Select File";
openFileDialog1.Filter = "All files (*.*)|*.*|XML File (*.xml)|*.xml";
openFileDialog1.FilterIndex = 1;
openFileDialog1.ShowDialog();
if (openFileDialog1.FileName != "")
{
ds.ReadXml(openFileDialog1.FileName);
dataGridView1.DataSource = ds.Tables[0];
MessageBox.Show("XML Data Imported");
}
}
private void export_Click(object sender, EventArgs e)
{
SaveFileDialog sfd = new SaveFileDialog();
sfd.Title = "Save File";
sfd.Filter = "XML File (*.xml)|*.xml";
sfd.ShowDialog();
if (sfd.FileName != "")
{
ds.WriteXml(sfd.FileName);
MessageBox.Show("The File is saved!");
}
}
}
}
Download the project of Visual Studio 2013 in DropBox Download