read contents of a xml file into a data grid view
Posted
by syedsaleemss
on Stack Overflow
See other posts from Stack Overflow
or by syedsaleemss
Published on 2010-04-13T12:06:13Z
Indexed on
2010/04/13
12:13 UTC
Read the original article
Hit count: 235
c#
Im using c# .net , windows form application. I have a XML file which contains two columns and some rows of data. now i have to fill this data into a data grid view. im using a button, when i click on the button an open dialog box will appear. i have to select the xml file name and when i click on open the contents of that xml file should come to the data grid view. i have tried with the following code:
{
XmlDataDocument xmlDatadoc=new XmlDataDocument();
XmlDatadoc.Dataset.ReadXml(filename);
ds=xmlDatadoc.Dataset;
datagridview1.DataSource=ds.DefaultViewManager;
datagridview1.Datamember="language";
}
My xml file is:
<languages>
<language>
<key> key1</key>
<value>value1</value>
<language>
<language>
<key> key2</key>
<value>value2</value>
<language>
</languages>
Its working fine but only for "language" . I need it to work file other xml files also.
© Stack Overflow or respective owner