I wanted to get a canonicalized version of a piece of xml by using nokogiri, though its canonicalize method is returnin an empty string.
d= Nokogiri::XML::Document.new '<a><z></z><b c="d">e</b></a>'
d.canonicalize #=> ""
Does anybody know what am I doing wrong? I am using Nokogiri 1.6.7
Document::new
doesn’t actually parse the document. You are basically just creating an empty document with a rather odd XML version:Instead use
Document::parse
, or theXML()
method on theNokogiri
module: