Using Rails 3 I am consuming an XML feed generated in drupal or something. The tags it gives me look like:
<body><![CDATA[<p>This is a title<br />A subheading</p>]]></body>
So the intention is that this should really look like:
<p>This is a title<br />A subheading</p>
Which could then be rendered in a view using <%= @mystring.html_safe %> or <%= raw @mystring %> or something. The trouble is that rendering the string in this way will simply convert substrings like < into the < character. I need a sort of double raw or double unencode to first deal with the chr and then render the tags as html safe.
Anyone know of anything like:
<%= @my_double_safed_string.html_safe.html_safe %>
I don’t think this is valid XML – they’ve sort of escaped the text twice in two different ways, by using entities and cdata. Still, you can parse it using nokogiri for example:
Seeing as this drupal site is spewing crazy double escaped xml, I’d be inclined to even use a regexp. Hacks to solve a problem hacks created? IDK. Regardless:
Hope this helps!