title: How to handle POSTed XML via Sinatra Ruby app
body: <p>I'm planning on using Sinatra for a new tiny webservice (WS) that I need to put together for a client.</p>
  
  <p>The WS will only have two methods, one accessed via GET and one via POST.  For the POST method, the client will send an XML packet to the sinatra WS which will parse the data and issue either a 200 OK HTTP response or a 40x error code.</p>
  
  <p>My question is how do I parse the incoming POSTed XML packet in Sinatra?</p>
  
  <p>Here is an example of what the incoming data packet will look like:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt;
  &lt;Counts&gt;
    &lt;OccupiedCount&gt;300&lt;/OccupiedCount&gt;
    &lt;ReservedCount&gt;40&lt;/ReservedCount&gt;
    &lt;VacantCount&gt;160&lt;/VacantCount&gt;
    &lt;TotalCount&gt;500&lt;/TotalCount&gt;
    &lt;Checksum&gt;0777d5c17d4066b82ab86dff8a46af6f&lt;/Checksum&gt;
    &lt;Timestamp&gt;2009-11-21T14:06:19Z&lt;/Timestamp&gt;
    &lt;ApiKey&gt;1234567890qwerty&lt;/ApiKey&gt;
  &lt;/Counts&gt;
  </code></pre>
  
  <p>Is there someway to access the data packet via the Sinatra params object so that I can parse it with something like Crack XML?  Or do I need to use some kind of Rack variable to get at the whole XML data packet that was POSTed to my WS?</p>