3. Writing DataSet Contents as XML
Data (ADO.NET)
• WriteScheme Method
– Writes the current contents of the DataSet as XML
data with the relational structure as inline XML
Schema.
• WriteXml method
– Using this method you can write the Dataset to a
file, stream, or XmlWriter.
4. Code Snippet
Dim mds As DataSet = mds.tables(“tblUser”)
mUserDS.WriteXml(“User.xml", XmlWriteMode.WriteSchema)
6. Loading a DataSet from XML
(ADO.NET)
• To fill a DataSet with data from XML, use the ReadXml
method of the DataSet object. The ReadXml method
reads from a file, a stream, or an XmlReader, and takes
as arguments the source of the XML.
• The ReadXml method reads the contents of the XML
stream or document and loads the DataSet with data. It
will also create the relational schema of the DataSet
depending on the XmlReadMode specified and whether
or not a relational schema already exists.
7. Code snippet
Dim m_Ds as Dataset
Public sub ReadXML()
m_User.ReadXml(“User.xml", XmlReadMode.ReadSchema)
End Sub