In Nokogiri 1.6.1, I'm observing the following behavior:
require 'nokogiri'
xml1 = Nokogiri::XML::Builder.new do |xml|
xml.p
end
xml1.to_xml #=> <?xml version="1.0"?>\n<p/>
xml2 = Nokogiri::XML::Builder.new do |xml|
xml.send(:p)
end
xml2.to_xml #=> <?xml version="1.0"?>
So, .p produces a <p/> element, while .send(:p) produces nothing. What's going on here? This behavior seems to contradict everything I've read about Nokogiri's API. It also seems illogical in terms of Ruby's semantics, unless that class overrides #send.
The same also happens with .send("p").
For reference:
How do I create XML using Nokogiri::XML::Builder with a hyphen in the element name?