I have a table in SQL server that is used to store submitted form data. The form fields for each submission are dynamic so the collected data is stored as name value pairs in an XML data column called [formdata] as in the example below...
This works fine for collecting the required information but I now need to render this data to a flat file or an excel document for processing by human staff members and im wondering what the best way of doing this would be using Xquery so that the data is readable?
The table is as follows...
[id], [user_id], [datestamp], [formdata]
And a sample value for formdata
<formfields>
<item>
<itemKey>USER_NAME</itemKey>
<itemValue>test</itemValue>
</item>
<item>
<itemKey>value2</itemKey>
<itemValue>test</itemValue>
</item>
<item>
<itemKey>MYID</itemKey>
<itemValue>5468512</itemValue>
</item>
<item>
<itemKey>testcheckbox</itemKey>
<itemValue>item1,item3</itemValue>
</item>
<item>
<itemKey>samplevalue</itemKey>
<itemValue>item3</itemValue>
</item>
<item>
<itemKey>accept_terms</itemKey>
<itemValue>True</itemValue>
</item>
</formfields>
Is this what you want?
Test:
Result: