Eggnog
Eggnog is a Nokogiri XML Node Class mixin that implements Node#to_hash
Installation
gem install eggnog
Usage
XML
<root>
<foo bar='baz'>Some text value</foo>
</root>
node = Nokogiri::XML(xml)
Default Behavior
node.to_hash
returns:
{
"root" => {
"foo" => "Some text value"
}
}
With Options
Preserve XML attributes:
node.to_hash(:preserve_attributes => true)
returns:
{
"root" => {
"foo" => {
"__content__" => "Some text value",
"bar" => "baz"
}
}
}
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Added some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request