# Parse XML POST/PUT into params hash

**URL:** <https://www.ruby-forum.com/t/parse-xml-post-put-into-params-hash/130412>\
**Category:** Rails\
**Created:** [February 28, 2008, 12:43am UTC](https://www.ruby-forum.com/t/parse-xml-post-put-into-params-hash/130412 "2008-02-28T00:43:39Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![makire](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/fbc32d/32.png) [@makire](https://www.ruby-forum.com/u/makire)\
**Post date:** [February 28, 2008, 12:43am UTC](https://www.ruby-forum.com/t/parse-xml-post-put-into-params-hash/130412/1 "2008-02-28T00:43:39Z")

</div>

I am creating a RESTful web service and want to allow the user to  
supply the POST/PUT representation as either url-encoded key/value  
pairs or XML. I have read in several sources that Rails will parse  
incoming XML into the params hash. The following data should be  
equivalent:

XML: Hello

url-encoded: product[test]=Hello

They should both result in the hash params = {“product” =\> {“test” =\>  
“Hello”}} (+ format, controller and action keys)

But when I do the following curl command:

> curl -u name:pass -i -X POST -d “Hej” [http://localhost:3003/product.xml](http://localhost:3003/product.xml)

the params hash looks like this:

{“\<dt\_order\>Hej\</dt\_order\>”=\>“”}

Does anyone have any input on why this happens and how to solve it. I  
am running 1.2.6 and a 2.0 migration is not possible since the  
application is in production.

Thanks in advance

Erik L.
