README.rdoc in smacks-apricoteatsgorilla-0.3.2 vs README.rdoc in smacks-apricoteatsgorilla-0.3.3

- old
+ new

@@ -12,26 +12,45 @@ == Dependencies Hpricot 0.6.164 (also available for JRuby) -== Translating an XML String into a Ruby Hash +== How to use - xml = "<apricot><eats>Gorilla</eats></apricot>" - ApricotEatsGorilla[xml] - # => { :eats => "Gorilla" } +=== xml_to_hash(xml, root_node = nil) -== Translating a Ruby Hash into an XML String + xml = '<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> + <soap:Body> + <ns2:authenticateResponse xmlns:ns2="http://v1_0.ws.example.com/"> + <return> + <authValue> + <token>secret</token> + <client>example</client> + </authValue> + </return> + </ns2:authenticateResponse> + </soap:Body> + </soap:Envelope>' + ApricotEatsGorilla[xml, "//return"] + # => { :auth_value => { :token => "secret", :client => "example" } } + +=== hash_to_xml(hash) + hash = { :apricot => { :eats => "Gorilla" } } + ApricotEatsGorilla[hash] # => "<apricot><eats>Gorilla</eats></apricot>" -== Creating a SOAP request envelope +=== soap_envelope(namespaces = {}) ApricotEatsGorilla.soap_envelope { "<authenticate>me</authenticate>" } # => '<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"> # => <env:Body> # => <authenticate>me</authenticate> # => </env:Body> - # => </env:Envelope>' + # => </env:Envelope>' + +== More examples + +Please take a look at the tests for some more examples. \ No newline at end of file