Iam writing a code to read XML file and display it in DataGridView, but it doesn't work, my code is as follows...
give me suggestions
DataTable an = new DataTable();
XmlDocument xmldoc=new XmlDocument();FileStream fsazm = new FileStream("D:\\data.xml", FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
xmldoc.Load(fsazm);
XmlNodeList xmlnode = xmldoc.GetElementsByTagName("Student");
for (int i = 0; i < xmlnode.Count; i++)
{
XmlAttributeCollection xattrc = xmlnode[i].Attributes;
an.Rows[i][0] = xattrc[0].Value;
an.Rows[i][1] = xattrc[1].Value;
}
VulpesPosted May 1, 2014, 5:47 AM
Anjan KumarPosted May 4, 2014, 6:07 AM
VulpesPosted May 1, 2014, 6:33 AM
http://msdn.microsoft.com/en-us/library/system.data.datatable.writexml(v=vs.110).aspx
Even if you only want to update the file, it's best just to recreate the whole thing from scratch which is what this method always does.
Anjan KumarPosted May 1, 2014, 6:16 AM
Lakshmanan Sethu SankaranarayanPosted May 1, 2014, 5:37 AM