2014年3月4日 星期二

vb net xsd dataset

MSDN:從 XML 載入 DataSet 結構描述資訊
MSDN:將 DataSet 結構描述資訊寫為 XSD
MSDN:將 DataSet 內容撰寫成 XML 資料
--
(1)XML(XSD) 載入 dataset
Dim dataSet As DataSet = New DataSet
dataSet.ReadXmlSchema("schema.xsd")

Dim xmlStream As System.IO.StreamReader = New System.IO.StreamReader ("schema.xsd");
Dim dataSet As DataSet = New DataSet
dataSet.ReadXmlSchema(xmlStream)
xmlStream.Close()


(2)dataset 寫入 XSD (XML)

dataSet.WriteXmlSchema("Customers.xsd")

Dim writer As System.IO.StreamWriter = New System.IO.StreamWriter("Customers.xsd")
dataSet.WriteXmlSchema(writer)
writer.Close()

Dim schemaString As String = dataSet.GetXmlSchema()

(3)將 DataSet 內容撰寫成 XML 資料
Dim xmlSW As System.IO.StreamWriter = New System.IO.StreamWriter("Customers.xml")
custDS.WriteXml(xmlSW, XmlWriteMode.WriteSchema)
xmlSW.Close()

沒有留言:

張貼留言