This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In Ruby 1.9.2 to escape XML special characters in Strings, use the 'encode' method. | |
Example, if you have: | |
my_string = 'this is "my" complicated <String>' | |
For XML attributes use: | |
"<node attr=#{my_string.encode(:xml => :attr)} />" | |
Generates: |