Parsing xml from post

I am working on an application where the client sends an xml string.
I was planning on using REXML and reading the raw post data. Then I
noticed that if the content type is text/xml, rails parses the xml
into the params hash. However, it chokes on attributes in the xml
such as the xml below, throwing an error that it can’t typecast the
attribute value in line 99 of cgi_methods.rb (snippet included below).
It would be nice just to use the built in xml parsing, but even if I
use REXML directly I’d like to get rid of this error. Anyone know how
to fix this (my code or rails wherever the real problem is) ?

<?xml version="1.0" encoding="UTF-8"?> test

def self.typecast_xml_value(value)
case value
when Hash
if value.has_key?(“content”)
content = translate_xml_entities(value[“content”])
case value[“type”]
when “integer” then content.to_i
when “boolean” then content == “true”
when “datetime” then Time.parse(content)
when “date” then Date.parse(content)
else content
end
else
value.empty? ? nil : value.inject({}) do |h,(k,v)|
h[k] = typecast_xml_value(v)
# <- line 99
h
end
end
when Array
value.map! { |i| typecast_xml_value(i) }
case value.length
when 0 then nil
when 1 then value.first
else value
end
else
raise “can’t typecast #{value.inspect}”
end
end