README.rdoc in smacks-apricoteatsgorilla-0.1.2 vs README.rdoc in smacks-apricoteatsgorilla-0.2.0
- old
+ new
@@ -1,24 +1,25 @@
= Apricot eats Gorilla
-Apricot eats Gorilla converts SOAP response messages to Ruby hashes.
-It's based on CobraVsMongoose but uses Hpricot instead of REXML and it
-also doesn't follow the BadgerFish convention.
+Apricot eats Gorilla translates between XML documents and Ruby hashes.
+It's based on CobraVsMongoose but uses Hpricot instead of REXML to parse
+XML and it also doesn't follow the BadgerFish convention.
+It's initial purpose was to convert SOAP response messages to Ruby hashes,
+but it quickly evolved into a more general translation tool.
+
== Install
- $ sudo gem sources -a http://gems.github.com
- $ sudo gem install smacks-apricoteatsgorilla
- $ sudo gem install hpricot
+ $ sudo gem install smacks-apricoteatsgorilla --source http://gems.github.com
== Dependencies
Hpricot 0.6.164 (also available for JRuby)
== An example
-Let's assume you receive the following SOAP response message:
+Let's assume you receive the following SOAP response:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<ns2:findCustomerByIdResponse xmlns:ns2="http://v1_0.ws.example.com/">
<return>
@@ -35,13 +36,13 @@
</soap:Body>
</soap:Envelope>
Just pass in the raw XML string like this:
- require 'rubygems'
- require 'apricoteatsgorilla'
- hash = ApricotEatsGorilla.soap_response_to_hash(xml)
+ require "rubygems"
+ require "apricoteatsgorilla
+ hash = ApricotEatsGorilla.xml_to_hash(xml, "//return")
And it gets converted into a nice little hash:
"empty" => false,
"customer" => {
@@ -52,14 +53,15 @@
"email" => "jj@example.com"
}
== The conclusion
-* It assumes a root node named "return", but you can pass in an XPath
- expession as the second parameter, to define a different root node.
-* All attributes are ignored and won't be included in the hash.
+* The xml_to_hash method starts parsing the XML at the root node by default.
+ By calling the method with an XPath expression as second parameter, we define
+ a custom root node.
+* Node attributes are ignored and won't be included in the hash.
* The value of empty element nodes will be nil.
-* Values of "true" or "false" will be converted to boolean objects.
+* Node values of "true" or "false" will be converted to boolean objects.
== For more information
-Take a look at the tests to see some more examples.
+Take a look at the tests for some more examples.