Updating XML with database information

Aleks
Aleks used Ask the Experts™
on
I have a Blob in my database which contains an XML string, with names of fields and their values.
Some of those fields match fields in tables in my database. like say 'name' or 'address', etc. and other fields are not matched to my database but info that is relevant for other purposes.

We have a routine to send this XML string to a web service to be processed. BUT we need to do this BEFORE we send the XML to the web service.

We need to update the XML with the information we have in our database, THEN send it to the web service, this update only applies to the fields that match fields in the database, so that the name of the field is the same, then we need to update the value in the XML with the value we have in the database.

This is because often times the information in the database changes, like addresses, phone numbers, etc. And when we saved the Blob (XML) it had old numbers or addresses. This way when we send the XML for processing we are sending it with the NEW information and not the old one.

We just don't know how to create code to update the fields in the XML that match fields in our database.
We have a table (UserMap) which has the list of all the fields we have in the DB.

We are using MS SQL 2008 R2
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Senior Developer
Commented:
Redundant information shouldn't be stored at all..

You can use the modify() and  nodes() method of the XML data type.

The rest depends on the concrete XML and data model, but I could get really ugly.

Author

Commented:
I agree. Ill close this ticket and look at the option of saving ONLY data that does NOT come from the DB.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial