How to create Nokogiri node if node name collide with Nokogiri::XML::Builder methods

Suppose you want to create node with name text, but this method already present in Nokogiri::XML::Builder. The solution is to add underscore after node name:

Nokogiri::XML::Builder.new do |xml|
  xml.text_ 'something' # this should create node with name 'text'
end
konjoot Over 9 years ago