CDATA sections in XML should do.
Here's a stackoverflow post about it:
I remember it took me a while to understand how to use them. A DOM parser has a dedicated instruction for creating a CDATA section but there is no equivalent statement for reading them. Reading is transparent, you just read the contents of the element that has the CDATA section in it to have the literal text returned.
Here's an example taken from the input data file of a code scrutinizer I once made. It allows the definition of the forms of problematic code fragments using regular expressions.
<IssueBuster type="Basic" name="Suspicious lambdas" skip="true">
<!-- See https://stackoverflow.com/questions/2465040/using-lambda-expressions-for-event-handlers -->
A lambda expression is used for event handlers which inhibits unsubscribing.
<!-- If any of these inner texts appears in a file path, this buster will ignore that file. -->
Note that CDATA takes this form:
Whatever you put in between the inner square brackets will be returned verbatim.
To wrap this up: in the unlikely event you have to include a ]]> sequence in the content, you can split the content after the second ] and create two consecutive CDATA sections. This can easily be implemented recursively.