Skip to content

Instantly share code, notes, and snippets.

@mperham
Created October 20, 2009 15:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mperham/214321 to your computer and use it in GitHub Desktop.
Save mperham/214321 to your computer and use it in GitHub Desktop.
>> x = Nokogiri::XML::Builder.new(:encoding => 'UTF-8') do |xml|
?> xml.feed do |ctx|
?> xml.title "This isn't a test & certainly does not test \"quotes\""
>> end
>> end
=> #<Nokogiri::XML::Builder:0x1013c5a30 @arity=1, @context=nil, @parent=<?xml version="1.0" encoding="UTF-8"?>
>> x.to_xml
=> "<?xml version="1.0" encoding="UTF-8"?>\n<feed>\n <title>This isn't a test &amp; certainly does not test "quotes"</title>\n</feed>\n"
The amp is encoded but shouldn't Nokogiri also encode &apos; and &quot; characters, per http://xml.silmaril.ie/authors/specials/?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment