Click to See Complete Forum and Search --> : XML as a DataSource


XScooterx
July 27th, 2009, 09:32 PM
Hello,
I am make an application with C#, VS 2005, that reads and writes info to an XML file.
I would like to add a report to display the information of the xml file.
How ever i can't seem to add the xml file as a data source for the report.
can someone please help me?
thank you

RaleTheBlade
July 28th, 2009, 05:00 PM
You could read the xml file into a DataSet object and use that. The DataSet (and DataTable) contains a function for reading in XML data from a file and storing it in a DataSet. You should create the DataSet first in code:


DataSet dataset = new DataSet("myDataSet");

// Read the xml data into the DataSet object
// The myDataFile.xml file must contain data formatted in
// such a way that it can be loaded into the DataSet
dataSet.ReadXml("myDataFile.xml");

// You can save the data to XML
// You may want to do this first so you have a file
// formatted for being read into the DataSet.
dataSet.WriteXml("myDataFile.xml");