DataSet Property
Collapse the table of content
Expand the table of content

XmlDataDocument.DataSet Property

Gets a DataSet that provides a relational representation of the data in the XmlDataDocument.

Namespace:  System.Xml
Assembly:  System.Data (in System.Data.dll)

public DataSet DataSet { get; }

Property Value

Type: System.Data.DataSet
A DataSet that can be used to access the data in the XmlDataDocument using a relational model.

The DataSet enables you to access the data in the XmlDataDocument using a relational model. This means that you can handle the data as tables and views, rows and columns, relations, and so on. Changes made in the DataSet are immediately visible in the XmlDataDocument.

The following example modifies the price of a book using the DataSet methods.

using System;
using System.Data;
using System.Xml;

public class Sample
  public static void Main()
     //Create an XmlDataDocument.
     XmlDataDocument doc = new XmlDataDocument();

     //Load the schema file.

     //Load the XML data.

     //Update the price on the first book using the DataSet methods.
     DataTable books = doc.DataSet.Tables["book"];
     books.Rows[0]["price"] = "12.95";  

     Console.WriteLine("Display the modified XML data...");
} // End class

The example uses the following two files as input.


<!--sample XML fragment-->
  <book genre='novel' ISBN='10-861003-324'>
    <title>The Handmaid's Tale</title>
  <book genre='novel' ISBN='1-861001-57-5'>
    <title>Pride And Prejudice</title>


<xsd:schema xmlns:xsd="">

 <xsd:element name="bookstore" type="bookstoreType"/>

 <xsd:complexType name="bookstoreType">
  <xsd:sequence maxOccurs="unbounded">
   <xsd:element name="book"  type="bookType"/>

 <xsd:complexType name="bookType">
   <xsd:element name="title" type="xsd:string"/>
   <xsd:element name="author" type="authorName"/>
   <xsd:element name="price"  type="xsd:decimal"/>
  <xsd:attribute name="genre" type="xsd:string"/>

 <xsd:complexType name="authorName">
   <xsd:element name="first-name"  type="xsd:string"/>
   <xsd:element name="last-name" type="xsd:string"/>


.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
© 2015 Microsoft