DataSets and XML - The Simplistic Approach

Posted on DotNetBlocks See other posts from DotNetBlocks
Published on Sun, 21 Nov 2010 22:24:00 -0500 Indexed on 2010/12/06 16:59 UTC
Read the original article Hit count: 291

Filed under:

One of the first ways I learned how to read xml data from external data sources was by using a DataSet’s ReadXML function. This function takes file path for an XML document and then converts it to a Dataset. This functionality is great when you need a simple way to process an XML document.  In addition the DataSet object also offers a simple way to save data in an xml format by using the WriteXML function. This function saves the current data in the DataSet to an XML file to be used later.

DataSet ds  = New DataSet();
String filePath = “http://www.yourdomain.com/someData.xml”;
String fileSavePath = “C:\Temp\Test.xml”
//Read file for this location
ds.readxml(filePath);
//Save file to this location
ds.writexml(fileSavePath);

I have used the ReadXML function before when consuming data from external Rss feeds to display on one of my sites.  It allows me to quickly pull in data from external sites with little to no processing.


Example site: MyCreditTech.com

© DotNetBlocks or respective owner

Related posts about Data Sources