Problem with dataset.getxml

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi

I am trying to convert a dataset to xml using dataset.getxml.
But this xml doesn't contain elements for null columns that are present in the dataset. How can we explicitly control this behaviour

Suppose I have this dataset

Col1 Col2 Col3 Col
----- ---- ---- ---
A1 A2 A3 A
B2 B3 B
C1 C2 C3 C

It can be noted that (Column1, Row2) element is blank. Now when I convert this dataset to xml using dataset.getxml, I get the following xml

<NewDataSet><Table><Col1>A1</Col1><Col2>A2</Col2><Col3>A3</Col3><Col4>A4</Col4></Table><Table><Col2>B2</Col2><Col3>B3</Col3><Col4>B4</Col4></Table><Table><Col1>C1</Col1><Col2>C2</Col2><Col3>C3</Col3><Col4>C4</Col4></Table></NewDataSet

As it can be noticed in the above xml, <Col1></Col1> element set is missing in the second <Table> node set.
If I want this in the xml, What do I have to do ? I tried using ds.WriteXML instead of getXML, but no luck. Any help would be highly appreciated. Thanks
 
Hi Kashyap,

You can use for serialization and deseralization (which is not possible with
GetXML) also this routine. (Both without schema as in GetXML).
\\\
' Serialization
Dim sw As New System.IO.StringWriter
ds.WriteXml(sw)
Dim mystring As String = sw.tostring

'Deserialization
Dim sr As New System.IO.StringReader(mystring)
Dim ds2 As New DataSet
ds2.ReadXml(sr)
///
I hope this helps,

Cor
 
Back
Top