Reputation: 2884
I have been following this article to read an XML file into a datagridview control.
I am posting the relevant piece of code here.
string filePath = "Complete path where you saved the XML file";
dsAuthors.ReadXml(filePath);
dataGrid1.DataSource = dsAuthors;
dataGrid1.DataMember = "authors";
dataGrid1.CaptionText = dataGrid1.DataMember;
Now I want to be able to read any XML file without knowing the elements of the XML file, but the above method requires me to declare the dataGrid1.DataMember = "authors";
which in case of random XML file, I will not know.
Thanks,
Abijeet.
Upvotes: 1
Views: 174
Reputation: 273294
With a little luck the following property has been filled:
dataGrid1.DataMember = dsAuthors.Tables[0].Tablename;
Upvotes: 2