I just wrote a small article on Loading an XML file into a Windows Form's DataGridView Control but got a question on how to do the same in WPF. Here is another related article : Save Data from a DataGridView to XML.
In this article, we will see how to load an XML into a WPF DataGrid control. If you have not worked with the DataGrid control, I recommend reading DataGrid in WPF.
In ADO.NET, the DataSet class implements methods and properties to work with XML documents.
The ReadXml method reads an XML file and loads it into a DataSet. ReadXml is an overloaded method; you can use it to read a data stream, TextReader, XmlReader, or an XML file and store it into a DataSet object, that can later be used to display the data in a tabular format.
The following code snippet loads the Books.xml file into a DataSet.
Sample
Use the following procedure to create the sample:
The output will be a DataGrid displaying the contents of an XML file.
Stay tuned. In my next articles, I will show how to add, update, and delete a XML file data from a DataGrid control.