chuyeow (owner)

Revisions

gist: 110925 Download_button fork
public
Public Clone URL: git://gist.github.com/110925.git
Embed All Files: show embed
Nokogiri's Builder and nodes like <id> and <type>.rb #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
builder = Nokogiri::XML::Builder.new do |xml|
  xml.listings {
    xml.language 'en'
 
    properties.each do |property|
 
      xml.listing {
        # Instantiate a Nokogiri::XML::Node and insert it manually.
        node = Nokogiri::XML::Node.new('id', doc) # doc is actually Nokogiri::XML::Builder#doc.
        node.content = property.id
        insert(node)
 
        xml.name property.name
      }
 
    end
  }
end