characterizeFile: validate XML before inserting to DB

This ensures that if the characterization tool returns invalid XML, it will not be saved to the database in order to avoid later issues with createMETS2.

For instance, in some circumstances FITS may print error output to the stdout stream alongside actual XML content, resulting in a document that will not parse.

Fixes #7422.
I notice the line before duplicates it... which it probably shouldn't