How to: Save a Dataset as XML
The XML data in a dataset can be accessed by calling the XML methods available on the dataset. For saving the data in XML format, you can call either themethod or the method of a .
Calling the GetXml method returns a string containing the data from all data tables in the dataset formatted as XML.
Calling the WriteXml method sends the XML-formatted data to a file you specify.
To save the data in a dataset as XML to a variable
The GetXml method returns a, so declare a variable of type String and assign it the results of the GetXml method.
To save the data in a dataset as XML to a file
The WriteXml method has several overloads. The following code shows how to save the data to a file, so declare a variable and assign it a valid path to save the file to.