README.rdoc in smacks-apricoteatsgorilla-0.2.2 vs README.rdoc in smacks-apricoteatsgorilla-0.2.3

- old
+ new

@@ -17,11 +17,11 @@ == An example Let's assume you receive the following SOAP response: - <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> +xml = '<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body> <ns2:findCustomerByIdResponse xmlns:ns2="http://v1_0.ws.example.com/"> <return> <empty>false</empty> <customer> @@ -32,18 +32,22 @@ <address /> </customer> </return> </ns2:findCustomerByIdResponse> </soap:Body> - </soap:Envelope> + </soap:Envelope>' Just pass in the raw XML string: require "rubygems" require "apricoteatsgorilla hash = ApricotEatsGorilla.xml_to_hash(xml, "//return") +Or use the shortcut: + + hash = ApricotEatsGorilla(xml, "//return") + And it gets converted into a nice little Hash: "empty" => false, "customer" => { "address" => nil, @@ -54,11 +58,11 @@ } == The conclusion * 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. + By calling the method with an XPath expression as second parameter, we're + able to 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. * Node values of "true" or "false" will be converted to boolean objects. == For more information