writing dataset to xml problem

  • Thread starter Thread starter R.A.
  • Start date Start date
R

R.A.

Hi

I have a web method that returns a string (which has an xml format).
I get a dataset and I need to convert the table in the dataset to xml and
then to send it as a string to the client. How can I do this?


Thanks
 
R.A.,

You can call the WriteXml method on the DataSet, passing a new instance
of a StringWriter. Once you have that, call that, you can call the ToString
method on the StringWriter class, and it should give you the string.

However, I was under the impression that if you returned just a dataset
from the web method, it would handle the formatting of that into XML.

Have you tried just returning the DataSet from the web method?

Hope this helps.
 
If I return Dataset wouldn't that force the web service consumer to use
Dataset? I prefer just to send back an xml.


Thanks

Nicholas Paldino said:
R.A.,

You can call the WriteXml method on the DataSet, passing a new instance
of a StringWriter. Once you have that, call that, you can call the ToString
method on the StringWriter class, and it should give you the string.

However, I was under the impression that if you returned just a dataset
from the web method, it would handle the formatting of that into XML.

Have you tried just returning the DataSet from the web method?

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

R.A. said:
Hi

I have a web method that returns a string (which has an xml format).
I get a dataset and I need to convert the table in the dataset to xml and
then to send it as a string to the client. How can I do this?


Thanks
 
R.A.,

It wouldn't force the web service consumer to use anything. From the
point of the web service consumer, they are getting XML. Now if you are
using a .NET proxy for it, then yes, it will use a DataSet, which you can
easily get the XML from.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

R.A. said:
If I return Dataset wouldn't that force the web service consumer to use
Dataset? I prefer just to send back an xml.


Thanks

in
message news:[email protected]...
R.A.,

You can call the WriteXml method on the DataSet, passing a new instance
of a StringWriter. Once you have that, call that, you can call the ToString
method on the StringWriter class, and it should give you the string.

However, I was under the impression that if you returned just a dataset
from the web method, it would handle the formatting of that into XML.

Have you tried just returning the DataSet from the web method?

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

R.A. said:
Hi

I have a web method that returns a string (which has an xml format).
I get a dataset and I need to convert the table in the dataset to xml and
then to send it as a string to the client. How can I do this?


Thanks
 
Back
Top