# Cobra vs Mongoose 0.0.1

**URL:** <https://www.ruby-forum.com/t/cobra-vs-mongoose-0-0-1/57949>\
**Category:** Ruby\
**Created:** [April 17, 2006, 12:31am UTC](https://www.ruby-forum.com/t/cobra-vs-mongoose-0-0-1/57949 "2006-04-17T00:31:57Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![paulbutcher](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/a5b964/32.png) [@paulbutcher](https://www.ruby-forum.com/u/paulbutcher)\
**Post date:** [April 17, 2006, 12:31am UTC](https://www.ruby-forum.com/t/cobra-vs-mongoose-0-0-1/57949/1 "2006-04-17T00:31:57Z")

</div>

Cobra vs Mongoose translates XML to and from Ruby Hash objects,  
following the BadgerFish ([http://badgerfish.ning.com/](http://badgerfish.ning.com/)) convention.

Usage

Converting XML to a Ruby Hash

require ‘cobravsmongoose’  
xml = ‘charliedavid’  
CobraVsMongoose.xml\_to\_hash(xml)

# =\> { “alice” =\> { “bob” =\> [{ “$” =\> “charlie” }, { “$” =\> “david” }]

} }

Converting a Ruby Hash to XML

require ‘cobravsmongoose’  
hash = { “alice” =\> { “$” =\> “bob”, “@charlie” =\> “david” } }  
CobraVsMongoose.hash\_to\_xml(hash)

# =\> “bob”

More information is available on the RubyForge page:  
[http://cobravsmongoose.rubyforge.org/](http://cobravsmongoose.rubyforge.org/)

Paul.
