Eggnog

travis

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

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Added some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request