<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: dataset code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Fri, 29 Aug 2008 07:40:04 GMT</pubDate>
    <description>DZone Snippets: dataset code</description>
    <item>
      <title>Dataset compression</title>
      <link>http://snippets.dzone.com/posts/show/3882</link>
      <description>&lt;code&gt;&lt;br /&gt;&lt;br /&gt;    private static byte[] DataSetCompress(DataSet dataSet)&lt;br /&gt;    {&lt;br /&gt;        MemoryStream ms = new MemoryStream();&lt;br /&gt;        BinaryFormatter bf = new BinaryFormatter();&lt;br /&gt;        DeflateStream ds = new DeflateStream(ms, CompressionMode.Compress);&lt;br /&gt;        bf.Serialize(ds, dataSet);&lt;br /&gt;        ds.Flush();&lt;br /&gt;        ds.Close();&lt;br /&gt;        return ms.ToArray();&lt;br /&gt;    }&lt;br /&gt;    private static DataSet DataSetDecompress(byte[] data)&lt;br /&gt;    {&lt;br /&gt;        BinaryFormatter bf = new BinaryFormatter();&lt;br /&gt;        MemoryStream ms = new MemoryStream(data);&lt;br /&gt;        DeflateStream ds = new DeflateStream(ms, CompressionMode.Decompress);&lt;br /&gt;        DataSet dataSet = (DataSet)bf.Deserialize(ds);&lt;br /&gt;        return dataSet;&lt;br /&gt;    }&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Tue, 24 Apr 2007 22:30:39 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/3882</guid>
      <author>mstampar (Miroslav Stampar)</author>
    </item>
    <item>
      <title>Output DataSet as XML</title>
      <link>http://snippets.dzone.com/posts/show/1975</link>
      <description>I was having problems with my ajax lookups when the database fields returned weird characters like the copyright symbol.  The responseXML would be blank.  After many searches I found you need to output in utf-8 and add an xml declaration to the output that says it is utf-8.  Here is the code below in vb.net for asp.net v1.1&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;   Private Sub OutputDataSetAsXML(ByRef dsSource As System.Data.DataSet)&lt;br /&gt;&lt;br /&gt;      Dim xmlDoc As System.Xml.XmlDataDocument&lt;br /&gt;      Dim xmlDec As System.Xml.XmlDeclaration&lt;br /&gt;      Dim xmlWriter As System.Xml.XmlWriter&lt;br /&gt;&lt;br /&gt;      ' setup response&lt;br /&gt;      Me.Response.Clear()&lt;br /&gt;      Me.Response.ContentType = "text/xml"&lt;br /&gt;      Me.Response.Charset = "utf-8"&lt;br /&gt;      xmlWriter = New System.Xml.XmlTextWriter(Me.Response.OutputStream, System.Text.Encoding.UTF8)&lt;br /&gt;&lt;br /&gt;      ' create xml data document with xml declaration&lt;br /&gt;      xmlDoc = New System.Xml.XmlDataDocument(dsSource)&lt;br /&gt;      xmlDoc.DataSet.EnforceConstraints = False&lt;br /&gt;      xmlDec = xmlDoc.CreateXmlDeclaration("1.0", "UTF-8", Nothing)&lt;br /&gt;      xmlDoc.PrependChild(xmlDec)&lt;br /&gt;&lt;br /&gt;      ' write xml document to response&lt;br /&gt;      xmlDoc.WriteTo(xmlWriter)&lt;br /&gt;      xmlWriter.Flush()&lt;br /&gt;      xmlWriter.Close()&lt;br /&gt;      Response.End()&lt;br /&gt;&lt;br /&gt;   End Sub &lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Wed, 03 May 2006 09:18:51 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/1975</guid>
      <author>Will_Rickards (Will Rickards)</author>
    </item>
  </channel>
</rss>
