in reply to How can I add missing XML open tags
I suggest trying a canonicalizer such as XML::CanonicalizeXML. Your supplied data is not valid XML to begin with, so you would need to address that problem first, I suspect.
In Section
Seekers of Perl Wisdom