How to return a cleaner XML structure using Dataset?

C

Chris

Hi-

I'd like to return the results of a stored procedure in a web service, and
want to know if there is a way to present a "cleaner" XML structure when
returning a dataset.

Right now, my class is structured like:

*private function to connect to DB / call stored procedure / fill dataset
*WebMethod to return dataset in XML

The contents of the XML structure are very messy, and I'd like to be able to
specify my own element labeling.

I'm at a loss as to the best method to present a definable XML structure in
the web service... Is it to manually define XML nodes?

Thanks,
Chris
 
J

Jan Tielens

I don't know how you can alter the xml being produced by a DataSet, but
maybe you could think about creating your own strongly typed collections, or
returning an array of custom objects. You'd have to create a data carrier
class: a class with some properties corresponding with the fields of a
DataTable. By doing so you can easily alter to resulting xml. For more
information you could read following articles:

http://www.topxml.com/xmlserializer/serialization_attributes.asp?printerversion=true
 
C

Chris

Thanks for the article link-

In the near term, I'm loading the resulting dataset in to an XmlDocument and
having the web method return that. It leaves out the schema and looks a bit
cleaner. I'm also going to manipulate some of the XmlDocument node names
prior to returning the doc as it seems a bit more manageable to do it this
way (the consumer of this web service only needs to read the xml structure).

Chris
 
M

Michael Pearson

You could use XSLT to transform the XML outputted by the dataset into
something you can work with.

Michael
 

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

Members online

Forum statistics

Threads
473,995
Messages
2,570,225
Members
46,815
Latest member
treekmostly22

Latest Threads

Top