Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Converting SQL Result Sets to XML

Tags:

sql

xml

I am looking for a tool that can serialize and/or transform SQL Result Sets into XML. Getting dumbed down XML generation from SQL result sets is simple and trivial, but that's not what I need.

The solution has to be database neutral, and accepts only regular SQL query results (no db xml support used). A particular challenge of this tool is to provide nested XML matching any schema from row based results. Intermediate steps are too slow and wasteful - this needs to happen in one single step; no RS->object->XML, preferably no RS->XML->XSLT->XML. It must support streaming due to large result sets, big XML.

Anything out there for this?

like image 224
tvaananen Avatar asked Sep 20 '26 00:09

tvaananen


1 Answers

With SQL Server you really should consider using the FOR XML construct in the query.

If you're using .Net, just use a DataAdapter to fill a dataset. Once it's in a dataset, just use its .WriteXML() method. That breaks your DB->object->XML rule, but it's really how things are done. You might be able to work something out with a datareader, but I doubt it.

like image 77
Joel Coehoorn Avatar answered Sep 22 '26 14:09

Joel Coehoorn



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!