Created
August 19, 2010 08:48
-
-
Save gunn/537425 to your computer and use it in GitHub Desktop.
Custom xml demo for IRC user
This file contains 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
def custom_xml hash | |
Builder::XmlMarkup.new(:indent => 2).tags do |tag| | |
hash.each do |key, val| | |
tag.tag! key do |v| | |
v.value val | |
end | |
end | |
end | |
end | |
custom_xml({:course => 'Java', :year => 'VT2010', :assignment => '1', :student => '2'}) |
This file contains 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
<tags> | |
<assignment> | |
<value>1</value> | |
</assignment> | |
<student> | |
<value>2</value> | |
</student> | |
<year> | |
<value>VT2010</value> | |
</year> | |
<course> | |
<value>Java</value> | |
</course> | |
</tags> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment