asp.net.ph

DataSet.WriteXml Method

System.Data Namespace   DataSet Class


Writes XML data, and optionally the schema, from the DataSet.

Overload List

1. Writes the current data for a DataSet using the specified Stream.

2. Writes the current data for a DataSet using the specified file.

3. Writes the current data for a DataSet using the specified TextWriter.

4. Writes the current data for a DataSet using the specified XmlWriter.

5. Writes the current data, and optionally the schema, for a DataSet using the specified Stream and XmlWriteMode. To write the schema, set the value for the XmlWriteMode parameter to WriteSchema.

6. Writes the current data, and optionally the schema, for a DataSet using the specified file and XmlWriteMode. To write the schema, set the value for the XmlWriteMode parameter to WriteSchema.

7. Writes the current data, and optionally the schema, for a DataSet using the specified TextWriter and XmlWriteMode. To write the schema, set the value for the XmlWriteMode parameter to WriteSchema.

8. Writes the current data, and optionally the schema, for a DataSet using the specified XmlWriter and XmlWriteMode. To write the schema, set the value for the XmlWriteMode parameter to WriteSchema.


Example

The following example initializes a System.IO.FileStream object that is used to create a new XmlTextWriter. The XmlTextWriter object is used with the WriteXml method to write an XML document.

NOTE: This example uses one of the overloaded versions of WriteXml. For other examples that may be available, see the individual overload topics.

private void WriteXmlToFile ( DataSet thisDataSet ) {
   if ( thisDataSet == null ) {
      return;
   }
   // create a file name to write to.
   string filename = "myXmlDoc.xml";
   // create the FileStream to write with.
   System.IO.FileStream myFileStream = new System.IO.FileStream
      ( filename, System.IO.FileMode.Create );
   // create an XmlTextWriter with the fileStream.
   System.Xml.XmlTextWriter myXmlWriter = 
      new System.Xml.XmlTextWriter ( myFileStream, System.Text.Encoding.Unicode );
   // Write to the file with the WriteXml method.
   thisDataSet.WriteXml ( myXmlWriter );   
   myXmlWriter.Close ( );
}
  C# VB

See Also

DataSet Members   WriteXmlSchema   ReadXml   ReadXmlSchema Skip Navigation Links




Home
Suggested Reading


Previous page Back to top Next page

© 2000-2010 Rey Nuñez All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note

You can help support asp.net.ph