Ruby Nokogiri Sax parser does not unescape & attribute

15 hours ago 2
ARTICLE AD BOX

With the following code:

require 'nokogiri' class MyDocument < Nokogiri::XML::SAX::Document def start_element_namespace(name, attrs = [], prefix = nil, uri = nil, ns = []) a = attrs.map {|e| [e.localname,e.value]}.to_h puts("name=#{name.inspect} #{a.inspect}") end end handler = MyDocument.new parser = Nokogiri::XML::SAX::Parser.new(handler) parser.parse('<root a="attribute &amp; cie"/>')

I get:

name="root" {"a"=>"attribute &#38; cie"}

&amp; is not unescaped by the parser. Why? It works for &lt; &gt;, but not &amp;

I don't understand

Read Entire Article