Appending a node to an existing XML file

In our project the SSRS RDLs are deployed by means of a MSI. The MSI was created with WIX which calls the RS.EXE thru custom action to deploy the report. The MSI provides the user with the ability to select or deselect  a report for/from deployment.

Once the reports are deployed to the report server, we need to do a sanity check, i.e. we had to run each report manually and ensure that nothing breaks. This becomes cumbersome especially when many reports are deployed. Since we are already using RS.EXE and RSS scripts, I thought of automating this sanity check by rendering the report automatically using RS.EXE.

The approach I took was like place the name and path of the report (we have many folders in the Report Server) which user selected for deployment in a XML file. Once the selected reports are deployed, loop thru the XML and render them into XLS. If there are any failures captures them into a log file for reference. Obviously this approach will work only for summary report. We need to do manual verification for drill thru (detail) reports.

When the first report is deployed, I just check whether the XML file already exists. If not then I will create one. The code was simple

From the second report onwards I have to append the node in the existing XML file. This is when the struggle started. I could find many suggestions in the NET but most of them are above my .NET knowledge. So one option I thought of was load the XML into a dataset , insert new records into it and write the dataset to a XML file (Is this because I am a DB guy? :)).

Before going this route finally I landed upon an article which talked about using CreateNode to fulfill this requirement (sorry I forgot the URL). Based on that approach I created a small procedure which helped me in getting out of this trouble. Here is the code

 Obviously there might be a better option than this but I am happy with this code as it serves my purpose.


About Suresh Kumar D

Hardcore SQL Developer and aspiring Database Architect.
This entry was posted in XML. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s