Save a dataset as XML

 

For the latest documentation on Visual Studio 2017, see Save a dataset as XML on docs.microsoft.com. The XML data in a dataset can be accessed by calling the available XML methods on the dataset. To save the data in XML format, you can call either the GetXml method or the WriteXml method of a DataSet.

Calling the GetXml method returns a string that contains the data from all data tables in the dataset that's formatted as XML.

Calling the WriteXml method sends the XML-formatted data to a file that you specify.

To save the data in a dataset as XML to a variable

  • The GetXml method returns a String.This means that you declare a variable of type String and assign it the results of the GetXml method.

    No code example is currently available or this language may not be supported.

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.Declare a variable and assign it a valid path to save the file to.

    No code example is currently available or this language may not be supported.

Save data back to the database

Show: