DataSets and Xml Representation PDF Print E-mail
User Rating: / 0
PoorBest 
Tuesday, 10 March 2009
HTML clipboard

One of the powerful features when using DataSet's is its ability to represent Xml data. There are a few ways that you can use Xml with the DataSet, today we are going to load an Xml document directly into the DataSet object.

So the method ReadXml() of the DataSet allows you to load a xml file into the DataSet.

Here's is the Xml file that I will be loading:

<csharpfriends>
<chapter>
<title>fun with xml</title>
<page>100</page>
</chapter>
<chapter>
<title>Dataset overview</title>
<page>187</page>
</chapter>
<chapter>
<title>Configuration</title>
<page>487</page>
</chapter>
</csharpfriends>

Keep in mind that the DataSet is going to figure out how to best represent the Xml, unless you use its ReadXmlSchema() method or you embed the schema directly into the Xml. Anyhow, we are going to keep it simple for now and let the DataSet do all our dirty work!

This example is fairly straight forward, I am going to load the above Xml into the DataSet and simply output the results using a DataGrid. Below is a live running example and the source code.

 
< Prev   Next >
School Joomla Templates and Joomla Tutorials