tenderlove (owner)

Revisions

gist: 181128 Download_button fork
public
Public Clone URL: git://gist.github.com/181128.git
Embed All Files: show embed
Ruby #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
require 'nokogiri'
 
xml = Nokogiri::XML::Builder.new(:encoding => 'UTF-8') do |xml|
  xml.feed(
    :xmlns => 'http://www.w3.org/2005/Atom',
    'xmlns:osa' => 'http://www.onespot.com/Atom/Extensions/1.0'
  ) do
 
    xml.title 'feed title', :type => "html"
 
    xml.entry do |ctx|
      ###
      # default namespace
      xml.title 'entry title', :type => "html"
 
      ###
      # "osa" namespace
      xml[:osa].score(0.50)
 
      ###
      # All of these tags belong to the "onespot" namespace
      ctx.with_namespace(:osa) do
        xml.foo(0.50)
        xml.bar(0.50)
 
        xml.baz do
          xml.yay
        end
      end
    end
  end
end.to_xml