Scott M.
2/16/2008 9:09:00 PM
I've got it working now. I was inadvertently using a StreamReader to read
the XML string in, rather than a StringReader. That's what I get for coding
at 3am!
Thanks.
"Scott M." <smar@nospam.nospam> wrote in message
news:ekGPvDCcIHA.5208@TK2MSFTNGP04.phx.gbl...
> I'm using a strongly-typed DataSet and its accompanying TableAdapter's
> Fill method to get data from my SQL Server database and that part is
> working just fine.
>
> I'm then using this dataset's GetXML method and passing that result via
> web service to a UI layer where an exact duplicate of the strongly typed
> dataset also exists.
>
> As I prepare to put the web serivices's xml into a new, but empty
> strongly-typed dataset, I am first using a StringReader to first receive
> the XML string and then I am using the dataset's ReadXML method and
> passing it my StringReader.
>
> The error is encountered when the DataSet attempts to load the
> StringReader via ReadXML. I have confirmed what the string is at this
> time and it does contain the \" escape sequence around the root element's
> xmlns value.
>
> Despite your statement that this couldn't block me from reading the string
> into the DataSet, I have confirmed that this is the problem. With these
> escape sequences in place, the string is not well-formed xml and will not
> load into the DataSet, without them (and just regular quotes), the string
> does load without issue.
>
> I will try using an XMLReader as you show below, but have always used
> StringReaders in the past without incident.
>
> -Scott
>
> "Wen Yuan Wang [MSFT]" <v-wywang@online.microsoft.com> wrote in message
> news:%231xjWd7bIHA.4196@TK2MSFTNGP04.phx.gbl...
>> Hello Scott,
>>
>> \" is an escape char in C#. It couldn't block you from passing it into
>> Dataset.
>> Could you please let me know how did you pass the xml representation into
>> another dataset?
>> Did you get any error message?
>>
>> I tried the following code on my side. It works fine. Would you please
>> try it and let me know the result?
>>
>> DataSet1TableAdapters.Table_1TableAdapter tt = new
>> WindowsApplication56.DataSet1TableAdapters.Table_1TableAdapter();
>> DataSet1 ds=new DataSet1();
>> tt.Fill(ds.Table_1);
>> string s = ds.GetXml();
>>
>> Byte[] xmlbyte=System.Text.Encoding.Default.GetBytes(s);
>> System.IO.MemoryStream ms = new System.IO.MemoryStream();
>> ms.Write(xmlbyte, 0, xmlbyte.Length);
>> ms.Position = 0;
>>
>> System.Xml.XmlReader xr = System.Xml.XmlReader.Create(ms);
>> DataSet1 ds2 = new DataSet1();
>> ds2.ReadXml(xr);
>>
>>
>> Hope this helps. Let me know if you face any further issue. We are glad
>> to assist you.
>>
>> Have a great day,
>> Best regards,
>>
>> Wen Yuan
>> Microsoft Online Community Support
>> ==================================================
>> This posting is provided "AS IS" with no warranties, and confers no
>> rights.
>
>