Surely whatever is putting in the <pasted_content ...> tags is also escaping the pasted content with e.g. < to &lt;

Put in a CDATA section and all bets are off. Maybe that is the next benchmark? Parse this XML correctly. Oh, by the way it must be valid, and here is a DTD. Using code is cheating.

But <![CDATA[xyz]]> would become &lt;![CDATA[some stuff]]>

[deleted]