Created
July 13, 2011 17:54
-
-
Save brookemckim/1080863 to your computer and use it in GitHub Desktop.
Build XML from template w/ Nokogiri
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template = File.read('/path/to/template') | |
builder = Nokogiri::XML::Builder.new do |xml| | |
eval File.read(template) | |
end | |
builder.to_xml |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
xml.root { | |
xml.categories { | |
@categories.each do |cat| | |
xml.category { | |
xml.title cat.title | |
xml.videos { | |
cat.videos.each do |vid| | |
xml.video { | |
xml.title vid.title | |
xml.description vid.description | |
xml.live vid.live | |
xml.format vid.format | |
xml.medias { | |
xml.media { | |
xml.url vid.url | |
xml.bitrate vid.bitrate | |
xml.quality vid.quality | |
} | |
} | |
xml.sd_image '' | |
xml.hd_image '' | |
} | |
end | |
} | |
} | |
end | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment