generates:#! /usr/bin/env ruby
require "nokogiri"
builder = Nokogiri::XML::Builder.new do |xml|
xml.root {
xml.products {
xml.send("referable-content") {
xml.id_ "10"
xml.name "Awesome widget"
}
}
}
end
puts builder.to_xml
Tag names are simply a message being sent to the builder object, which intercepts with #method_missing. Does that make sense?<?xml version="1.0"?>
<root>
<products>
<referable-content>
<id>10</id>
<name>Awesome widget</name>
</referable-content>
</products>
</root>
--
You received this message because you are subscribed to the Google Groups "nokogiri-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nokogiri-tal...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/nokogiri-talk/46db8a99-ad73-5c94-ce98-811622e2893a%40att.net.