I believe that
XML::LibXML can also do this directly, by passing a parameter of 1 or 2 to the
toString method. Yes, it'd be a parse, rather than regex matching, so it'd have to be well-formed XML.
-- Randal L. Schwartz, Perl hacker
Be sure to read my standard disclaimer if this is a reply.