Skip to content

Instantly share code, notes, and snippets.

@cmilfont
Created November 10, 2011 14:56
Show Gist options
  • Save cmilfont/1355031 to your computer and use it in GitHub Desktop.
Save cmilfont/1355031 to your computer and use it in GitHub Desktop.
Fazendo merge de Elements para gerar xml com Nokogiri
require 'nokogiri'
xml = Sistema.all.to_xml
builder = Nokogiri::XML::Builder.new(:encoding => 'UTF-8') do |xml|
xml.relatorio {
xml.nome "Milfont"
}
end
@doc = Nokogiri::XML(xml)
doc = Nokogiri::XML(builder.to_xml)
item = doc.at_css "relatorio"
item.add_child @doc.root
doc.to_xml #xupa!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment