Skip to content

Instantly share code, notes, and snippets.

@rickhull
Created September 15, 2010 20:45
Show Gist options
  • Select an option

  • Save rickhull/581451 to your computer and use it in GitHub Desktop.

Select an option

Save rickhull/581451 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'nokogiri'
include Nokogiri::XML
b = Builder.new {
fields {
field '1'
field '2'
}
}
puts b.to_xml
#<?xml version="1.0"?>
#<fields>
# <field>1</field>
# <field>2</field>
#</fields>
# now, given b, we want to add a root node, e.g.
#
#<?xml version="1.0"?>
#<root>
# <fields>
# <field>1</field>
# <field>2</field>
# </fields>
#</root>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment