How to convert a Dataset into a xml strin

M

Michael Kugler

Hi NG

How is it possible to convert a dataset into a XML string without saving it
to a file?
ds.writetoxml() only allows a filename.


---
Mit freundlichen Grüßen / Yours sincerely ,

Michael Kugler


Compunited
Inh.: Michael Kugler
Hasellohweg 19
90766 Fürth
Germany

Tel +49(911)1327142
Fax +49(911)1327143

Cell Phone +49(162)2656942
 
P

Peter Foot [MVP]

In .NETCF v1.0 you'll need to write to a file, read the file contents and
then delete it. In .NETCF v2.0 you can use the WriteXml overload which takes
a stream and write to a memory stream or whatever you require.

Peter
 
M

Michael Kugler

Hi Ilya

This works excelent. Is there also a new way for getting XML to dataset in
2.0
Right now i'm doing it like that:

Me.StatusBar1.Text = "fetch Artikel"
Me.StatusBar1.Refresh()

lcxml = ws.GetArtikelTable(1)

buffer = System.Text.Encoding.ASCII.GetBytes(lcxml)

ms = New System.IO.MemoryStream(buffer)

xtr = New System.Xml.XmlTextReader(ms)

ds = New Data.DataSet

ds.ReadXml(xtr, Data.XmlReadMode.InferSchema)

xtr.Close()

ms.Close()
 
I

Ilya Tumanov [MS]

That's pretty much as good as it gets with strings - very slow and nasty
with several copies of the same thing in memory.



The right way to do it is to change WS (I'm assuming you're using Web
Services) to return/take dataset instead of string.



Also, using inference is asking for troubles as it could produce results you
do not expect or fail. It also very slow and takes tons of memory.

DataSet with schema in any form (Typed DS with embedded schema, schema
loaded separately, schema in XML file with data or schema created
programmatically) is the way to go.



If XML string you sending was not produced by DataSet, it might fail as
well.


--
Best regards,

Ilya

This posting is provided "AS IS" with no warranties, and confers no rights.

*** Want to find answers instantly? Here's how... ***

1. Go to
http://groups-beta.google.com/group/microsoft.public.dotnet.framework.compactframework?hl=en
2. Type your question in the text box near "Search this group" button.
3. Hit "Search this group" button.
4. Read answer(s).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top