Wednesday, February 15, 2012

Exporting SQL Server 2005 data into formatted XML file

Hello,

I currently have a stored procedure in my SQL Server 2005 database that contains a simple SELECT FOR XML statement. I would like to call this stored procedure in C# and use C# to write an XML file such that when I open it in Visual Studio for editing it looks properly nested (rather than all on one line). Is there a quick way to do this?

I would like the file to look something like the following when opened:

Code Snippet

<Element1>

<Element2>

<Element3>Text</Element3>

<Element4>Text</Element4>

</Element2>

</Element1>

Thanks.

Create a DataSet put your table in it and call the DataSet.ReadXML method, if you want formatting you can use a Repeater for Webform. Try the link below to get started.

http://msdn2.microsoft.com/en-us/library/360dye2a.aspx

|||Thanks for your reply! I will look into that.

No comments:

Post a Comment