Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Magically navigate through xml as if it were a ruby object
Branch: lib-xml
Pull request Compare This branch is even with commonthread:lib-xml.

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
test
.gitignore
CHANGELOG
LICENSE
README.rdoc
Rakefile
demo.rb
xml-magic-0.1.0.gem
xml-magic-0.1.1.gem
xml_magic.gemspec

README.rdoc

xml-magic makes accessing xml objects more like any other ruby object

example

require 'xml_magic'

xml = <<XML
<project title="XML Magic">
  <description>Test description.</description>
  <contact type="Project Manager">Anthony</contact>
  <contact type="Worker Bee">Ben</contact>
  <contact type="Designer Bee">Jason</contact>
</project>
XML

project_info = CommonThread::XML::XmlMagic.new(xml)

puts project_info[:title]
puts project_info.description
for contact in project_info.contact
  puts "#{contact} the #{contact[:type]}"
end

example output

XML Magic
Test description.
Anthony the Project Manager
Ben the Worker Bee
Jason the Designer Bee

LibXml (faster parsing)

LibXML is not included in the standard ruby installation. You can download it from http://libxml.rubyforge.org/
To use LibXML simply instantiate your XmlMagic object like so: CommonThread::LibXML::XmlMagic.new(xml)
Something went wrong with that request. Please try again.