I think this is a hard problem to solve. I believe SQL Server,
XmlSerialization etc - all just ignore whitespace, but in those there are
methods to tell not to discard whitespace, I am not quite sure what you'd
have to do with a Dataset.
- Sahil Malik [MVP]
Upcoming ADO.NET 2.0 book -
http://tinyurl.com/9bync
----------------------------------------------------------------------------
---------------
"Tom Jastrzebski" <(E-Mail Removed)> wrote in message
news:ndtre.814$(E-Mail Removed)...
> Right, my data hast to be serialized to XML - that's a requirement.
> What causes the problem is actually deserialization, rather than
> serialization.
> I guess it is one of those bugs which will never be fixed due to low
> exposure.
>
> Tom
>
>
> "Sahil Malik [MVP]" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > Actually you aren't missing anything. I figured that due to the
> > serialization/deserialization process your data is getting mangled -
which
> > the datasetsurrogate will prevent. But I think you want the final output
> > as XML - right?
> >
> > - Sahil Malik [MVP]
> > Upcoming ADO.NET 2.0 book - http://tinyurl.com/9bync
>
> --------------------------------------------------------------------------
--
> >
> > "Tom Jastrzebski" <(E-Mail Removed)> wrote in message
> > news:3gpre.773$(E-Mail Removed)...
> >> Sahil,
> >>
> >> Thank you for your answer.
> >> However, I am not sure it helps solves my problem. It looks like
> >> DatasetSurrogate is designed to serialize data to/from binary format,
> >> while I am only interested in XML. Am I missing something?
> >>
> >> Tom
> >>
> >>
> >> "Sahil Malik [MVP]" <(E-Mail Removed)> wrote in message
> >> news:(E-Mail Removed)...
> >>> Tom,
> >>>
> >>> Look up "DatasetSurrogate" - that does not have this issue, and it
will
> >>> work with .NET 1.1 (plus it has a few other advantages like much
better
> >>> performance).
> >>>
> >>> - Sahil Malik [MVP]
> >>> Upcoming ADO.NET 2.0 book - http://tinyurl.com/9bync
>
>>> ------------------------------------------------------------------------
----
> >>>
> >>> "Tom Jastrzebski" <(E-Mail Removed)> wrote in message
> >>> news:M0Qqe.8283$(E-Mail Removed)...
> >>>> Hello everybody,
> >>>>
> >>>>
> >>>>
> >>>> It looks like this is a known problem, but I found no solution.
> >>>> Deserialization of DataSet object from XML does not preserve white
> >>>> space.
> >>>>
> >>>> The same code executed under .Net Framework 2.0 works, so apparently
> >>>> problem got fixed. As a fix xml:space="preserve" attribute is being
> >>>> added where appropriate.
> >>>>
> >>>>
> >>>>
> >>>> Here are two questions:
> >>>>
> >>>>
> >>>>
> >>>> 1. Consequently, DataSet serialized under .Net Framework 2.0 does NOT
> >>>> deserialize under 1.1. Is/will it be possible to maintain backwards
> >>>> compatibility, so data can be exchanged between different versions of
> >>>> MS .Net Framework?
> >>>>
> >>>>
> >>>>
> >>>> 2. More important to me right now: is there any way to deserialize
Data
> >>>> set from XML and preserve white space under .Net Famework 1.1?
> >>>>
> >>>>
> >>>>
> >>>> Thanks,
> >>>>
> >>>> Tom
> >>>>
> >>>>
> >>>>
> >>>>
> >>>>
> >>>> Sample code demonstrating the problem - it passes under .Net 2.0 but
> >>>> fails under 1.1
> >>>>
> >>>> - btw, using XmlTextReader does not help
> >>>>
> >>>>
> >>>>
> >>>> using System;
> >>>> using System.Data;
> >>>> using System.IO;
> >>>>
> >>>> class Program
> >>>> {
> >>>> static void Main(string[] args)
> >>>> {
> >>>> DataSet ds1 = new DataSet();
> >>>> DataTable dt = new DataTable();
> >>>> ds1.Tables.Add(dt);
> >>>> dt.Columns.Add("column1", typeof(string));
> >>>> dt.Rows.Add(new object[] { " " }); // add row containing
single
> >>>> space
> >>>>
> >>>> // serialize
> >>>> MemoryStream ms = new MemoryStream();
> >>>> ds1.WriteXml(ms);
> >>>>
> >>>>
> >>>>
> >>>> // deserialize
> >>>> ms.Position = 0;
> >>>> DataSet ds2 = new DataSet();
> >>>> ds2.ReadXml(ms);
> >>>>
> >>>> string value = (string)ds2.Tables[0].Rows[0]["column1"];
> >>>>
> >>>> if (value == " ") { // test if row contains single space
> >>>> Console.WriteLine("passed");
> >>>> } else {
> >>>> Console.WriteLine("failed");
> >>>> }
> >>>> Console.Read();
> >>>>
> >>>> }
> >>>> }
> >>>>
> >>>>
> >>>
> >>>
> >>
> >>
> >
> >
>
>