O'Reilly logo

Programming Microsoft® ADO.NET 2.0 Core Reference, 2nd Edition by David Sceppa

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Reading and Writing XML Data

First let’s examine the different ways we can read and write XML data using the DataSet class.

The DataSet Class’s XML Methods

The DataSet class has a series of methods that let you examine its contents as XML, as well as load XML data into the DataSet.

GetXml Method

The simplest of these XML methods is the GetXml method, which you can use to extract the contents of your DataSet and place them into a string. The GetXml method is simple, almost to a fault. It is not overloaded and accepts no parameters.

Figure 12-1 shows the contents of a DataSet in the Console window. The code that generates and displays this DataSet follows. The code snippet retrieves orders and line items for a customer using a function we’ll reuse in ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required