curv
curv

Reputation: 3844

Encoding html in rails

I'm currently working with many XML files and some of the data is encoded as below. How do I work with this data? Up until now I have been just simply using gsub() to replace the characters for blanks! Maybe there is an easier way.

Here is the description <br><br
>Here is some more text

I have been doing this:

gsub('&','')

Or this:

gsub('&','&')

Upvotes: 1

Views: 417

Answers (1)

jrichardlai
jrichardlai

Reputation: 3357

I think you can use CGI.unescapeHTML to decode the data http://ruby-doc.org/stdlib/libdoc/cgi/rdoc/classes/CGI.html#M000096. I hope this would help.

Upvotes: 2

Related Questions