# Problem in posting xml content

**URL:** <https://www.ruby-forum.com/t/problem-in-posting-xml-content/100743>\
**Category:** Rails\
**Created:** [July 31, 2006, 9:16pm UTC](https://www.ruby-forum.com/t/problem-in-posting-xml-content/100743 "2006-07-31T21:16:17Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![oliver](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/85f322/32.png) [@oliver](https://www.ruby-forum.com/u/oliver)\
**Post date:** [July 31, 2006, 9:16pm UTC](https://www.ruby-forum.com/t/problem-in-posting-xml-content/100743/1 "2006-07-31T21:16:17Z")

</div>

When I post the XML data as the message content to my rails website, I  
can see the exception info in the log file. The error message is “can’t  
typecast” the element name in my xml document.

The first line in backtrace is:  
“c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action\_controller/cgi\_ext/cgi\_methods.rb:111:in`typecast\_xml\_value’”

Please give me some information on how to settle this problem. Thanks.

---

<div class="post-metadata">

**Author:** ![oliver](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/85f322/32.png) [@oliver](https://www.ruby-forum.com/u/oliver)\
**Post date:** [July 31, 2006, 9:37pm UTC](https://www.ruby-forum.com/t/problem-in-posting-xml-content/100743/2 "2006-07-31T21:37:52Z")

</div>

oliver wrote:

> When I post the XML data as the message content to my rails website, I  
> can see the exception info in the log file. The error message is “can’t  
> typecast” the element name in my xml document.
> 
> The first line in backtrace is:  
> “c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action\_controller/cgi\_ext/cgi\_methods.rb:111:in`typecast\_xml\_value’”
> 
> Please give me some information on how to settle this problem. Thanks.

Sounds like something is wonky with your XML syntax. LIke maybe it  
can’t tell if it’s a number or a string or something.

Try adding 1 style tags into your XML and see  
if that helps.

---

<div class="post-metadata">

**Author:** ![oliver](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/85f322/32.png) [@oliver](https://www.ruby-forum.com/u/oliver)\
**Post date:** [July 31, 2006, 9:52pm UTC](https://www.ruby-forum.com/t/problem-in-posting-xml-content/100743/3 "2006-07-31T21:52:07Z")

</div>

On 7/31/06, oliver [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> When I post the XML data as the message content to my rails website, I  
> can see the exception info in the log file. The error message is “can’t  
> typecast” the element name in my xml document.
> 
> The first line in backtrace is:  
> “c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action\_controller/cgi\_ext/cgi\_methods.rb:111:in`typecast\_xml\_value’”

Are you passing attributes with the elements? I’ve found that rails  
can’t handle attributes and croaks with just that message.

---

<div class="post-metadata">

**Author:** ![oliver](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/85f322/32.png) [@oliver](https://www.ruby-forum.com/u/oliver)\
**Post date:** [August 1, 2006, 3:25pm UTC](https://www.ruby-forum.com/t/problem-in-posting-xml-content/100743/4 "2006-08-01T15:25:35Z")

</div>

oliver wrote:

> When I post the XML data as the message content to my rails website, I  
> can see the exception info in the log file. The error message is “can’t  
> typecast” the element name in my xml document.
> 
> The first line in backtrace is:  
> “c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action\_controller/cgi\_ext/cgi\_methods.rb:111:in`typecast\_xml\_value’”
> 
> Please give me some information on how to settle this problem. Thanks.

Thanks for attention.

I have found the reason.

In rails it defaults to using XmlSimple to parse the xml content.

I just need to reset ActionController::Base.param\_parsers[Mime::XML] to  
do nothing, then the error message disappear.
