Well, provided that you want the actual Ruby code itself, your problem is not with the parser, but the fact that your XML is malformed.
I'm still assuming your XML looks something like this:
<parent>
<node>
<% some code here! %>
</node>
</parent>
If that is indeed the case, the contents of the node
node (heh) should actually be a CDATA
section. So it should look like this:
<node><![CDATA[
<% some code here! %>
]]></node>
If you do this, REXML will be able to properly parse the XML file, and return the contents of node
, which will include the erb tags.
If you do not have control over the generation of the XML, you could, as a stop-gap fix, just (assuming that any given node that contains ERB only contains ERB) do a file wide search and replace for the start and end code tags, and appropriately append/prepend the CDATA markup. You could easily automate this in your language of choice, there's plenty of examples here on SO.