# Parse XML POST/PUT into params hash

**URL:** <https://discuss.rubyonrails.org/t/parse-xml-post-put-into-params-hash/25557>\
**Category:** rubyonrails-talk\
**Created:** [February 27, 2008, 11:41pm UTC](https://discuss.rubyonrails.org/t/parse-xml-post-put-into-params-hash/25557 "2008-02-27T23:41:02Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Erik\_Lindblad1](https://avatars.discourse-cdn.com/v4/letter/e/3da27b/32.png) [@Erik\_Lindblad1](https://discuss.rubyonrails.org/u/Erik_Lindblad1)\
**Post date:** [February 27, 2008, 11:41pm UTC](https://discuss.rubyonrails.org/t/parse-xml-post-put-into-params-hash/25557/1 "2008-02-27T23:41:02Z")

</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: \<product\>\<test\>Hello\</test\>\</product\>

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 "\<product\>\<test\>Hej\</test\>\</product\>" [http://localhost:3003/product.xml](http://localhost:3003/product.xml)

the params hash looks like this:

{"\<dt\_order\>\<test\>Hej\</test\>\</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 Lindblad
