the xml file my code is generating is as follows
<?xml version="1.0"?>
<DataClass xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<pathI>D:\POC\Input\2</pathI>
<pathO>D:\POC\Output</pathO>
<prefix>2_</prefix>
<frequency>25</frequency>
</DataClass><?xml version="1.0"?>
<DataClass xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<pathI>D:\POC\Input\3</pathI>
<pathO>D:\POC\Output</pathO>
<prefix>3_</prefix>
<frequency>33</frequency>
</DataClass>
I want to add a root element to the xml so that i can further use the xml to populate a data grid view. if possible also want to eliminated tag from every node.. help needed
DataClass data = new DataClass();
data.pathI = txt_input.Text;
data.pathO = txt_Output.Text;
data.frequency = Convert.ToInt32(txt_freq.Text);
data.prefix = txt_prefix.Text;
XmlDocument doc = new XmlDocument();
XmlSerializer xs = new XmlSerializer(typeof(DataClass));
if (!File.Exists("Data.xml"))
{
using (FileStream fs = new FileStream("Data.xml", FileMode.Create))
{
xs.Serialize(fs, data);
fs.Close();
fs.Dispose();
MessageBox.Show("Data loaded to the xml");
}
}
else if (File.Exists("Data.xml"))
{
using (FileStream fs = new FileStream("Data.xml",FileMode.Append))
{
xs.Serialize(fs, data);
fs.Close();
fs.Dispose();
MessageBox.Show("Data loaded to the xml");
}
}