Best way to insert XML data into DB?

We store a number of XML snippets and templates in our database, and updating these is one of the areas where developer collisions have become quite frequent, driving me to evaluate Liquibase.

I’m trying to determine if Liquibase is appropriate for this task, and what the best way to do it within liquibase is.

Consider some template data like this:


I can see two ways of doing this:

The first is escape and inline it in a changeset:

        \n    %value\n" />

This is ugly and requires massaging the data before putting it into the changelog. It gets particularly awkward with longer templates.

The alternative I see is to put this into a small .sql or .csv file and use or . This has the disadvantage of moving the actual changes out of the changelog, as well as creating a plethora of small throwaway files around the changelog.

This would be the ideal solution, something like this:

                <![CDATA[                     %value                 ]]>    

Any suggestions or advice?

Thanks in advance. :slight_smile:

I think you can use the colum tag body as the value rather than the value tag.  Try it out with the cdata block and let me k ow if it works.


Yep, the CDATA worked.

I guess I should have just tried it, huh. :wink: