Anjan Kumar

Anjan Kumar

  • NA
  • 6
  • 2.2k

Unable to read from XML file

May 1 2014 5:31 AM
 
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;
}

Answers (5)