# To\_xml and underscores

**URL:** <https://www.ruby-forum.com/t/to-xml-and-underscores/65033>\
**Category:** Rails\
**Created:** [August 15, 2006, 7:12pm UTC](https://www.ruby-forum.com/t/to-xml-and-underscores/65033 "2006-08-15T19:12:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![robkuz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/34f0e0/32.png) [@robkuz](https://www.ruby-forum.com/u/robkuz)\
**Post date:** [August 15, 2006, 7:12pm UTC](https://www.ruby-forum.com/t/to-xml-and-underscores/65033/1 "2006-08-15T19:12:46Z")

</div>

hi,

i am looking for a solution whereupon  
calling myEntityObject.to\_xml does not  
convert my attributes containing underscores  
into hyphens.

at the moment an attribute named “my\_own\_attribute”  
is converted into .

does anybody have an idea how to change that  
and have to\_xml generate \<my\_own\_attribute\>

thanks

ciao robertj

---

<div class="post-metadata">

**Author:** ![robkuz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/34f0e0/32.png) [@robkuz](https://www.ruby-forum.com/u/robkuz)\
**Post date:** [August 15, 2006, 7:27pm UTC](https://www.ruby-forum.com/t/to-xml-and-underscores/65033/2 "2006-08-15T19:27:11Z")

</div>

On 8/15/06, Robert K. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> does anybody have an idea how to change that  
> removed\_email\_address@domain.invalid  
> [http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)

Robert,  
Monkeypatch the to\_xml() method.  
Or create a patch where to\_xml() could take a :underscore =\> false  
parameter and submit to trac. Perhaps others would want this  
functionality…

---

<div class="post-metadata">

**Author:** ![robkuz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/34f0e0/32.png) [@robkuz](https://www.ruby-forum.com/u/robkuz)\
**Post date:** [August 15, 2006, 7:57pm UTC](https://www.ruby-forum.com/t/to-xml-and-underscores/65033/3 "2006-08-15T19:57:16Z")

</div>

Zack C. wrote:

> > Rails mailing list  
> > removed\_email\_address@domain.invalid  
> > [http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)
> 
> Robert,  
> Monkeypatch the to\_xml() method.  
> Or create a patch where to\_xml() could take a :underscore =\> false  
> parameter and submit to trac. Perhaps others would want this  
> functionality…

I put in a patch that was committed into RoR Edge where you can pass  
:dasherize  
=\> false to to\_xml() and it won’t dasherize your attributes. Hopefully,  
it’ll  
be in 1.2.

Regards,  
Blair
