Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bakkdoor/srxml
SRXML - Simple Ruby XML
https://github.com/bakkdoor/srxml
Last synced: 3 months ago
JSON representation
SRXML - Simple Ruby XML
- Host: GitHub
- URL: https://github.com/bakkdoor/srxml
- Owner: bakkdoor
- License: other
- Created: 2008-08-31T17:57:11.000Z (over 16 years ago)
- Default Branch: master
- Last Pushed: 2008-09-22T21:35:35.000Z (over 16 years ago)
- Last Synced: 2024-10-31T14:26:45.818Z (3 months ago)
- Language: Ruby
- Homepage:
- Size: 137 KB
- Stars: 4
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README
- License: LICENSE
Awesome Lists containing this project
README
=========================
SRXML - Simple Ruby XML
Created by Christopher Bertels ([email protected] / http://github.com/bakkdoor/)
=========================
SRXML is a very (super, if you will!) lightweight xml generator for Ruby. No big magic here, it simply uses method_missing to create the tags. There is some plan to make it more useful. For Example being able to parse existing files etc. but there are probably better libraries to do that.
If you simply want to create an xml file without the need for extra fancy formatting, SRXML could just be the deal for you!Oh, by the way. It also supports html-output now.
=========================
LICENSE:SRXML is licensed under the terms of the GNU GPL v2.
Play with it as much as you like, fork it and put the changes here back on github or so :)
=========================
==================================
Short Example (from examble.rb):
==================================
require "rubygems"
require "srxml"xml = SRXML::XML.new
xml.projects{
xml.project(:name => "project #1", :description => "some text", :id => 1){
xml.something_else "yo!"
}
}puts xml.to_s
Will output the following:
yo!You can also use some simple formatting:
puts xml.to_s(:formatted)
Which will then give you something like this:
yo!
==================================
Simple HTML generation:
==================================SRXML now also supports html-output:
require "rubygems"
require "srxml"
html = SRXML::XML.new :xml => false, :html => true # this will automatically set SRXML into 'html-mode',
# knowing for example, that certain tags are single (no end tag)
html.html{
html.head{
html.title "my title"
}
html.body{
html.div(:style => "padding:10em; font-size: 140%"){
"hello, world!"
}
}
}
puts html.to_sWill output the expected html-output.
For more examples take a look in the example-files.