# Custom XML Builder element needed

**URL:** <https://www.ruby-forum.com/t/custom-xml-builder-element-needed/126768>\
**Category:** Rails\
**Created:** [January 22, 2008, 1:30am UTC](https://www.ruby-forum.com/t/custom-xml-builder-element-needed/126768 "2008-01-22T01:30:54Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![The\_Cool\_Web\_Guy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/bbe5ce/32.png) [@The\_Cool\_Web\_Guy](https://www.ruby-forum.com/u/The_Cool_Web_Guy)\
**Post date:** [January 22, 2008, 1:30am UTC](https://www.ruby-forum.com/t/custom-xml-builder-element-needed/126768/1 "2008-01-22T01:30:54Z")

</div>

Hi all,

This may seem like a bit of a stupid question, I’m building an xml  
request to be sent over https to a service provider, but according to  
their specification, which doesn’t seem to work with the rails  
xmlbuilder and rxml templates, what I need is a way to create elements  
containing a hyphen in the name, like xxxxx  
but I can’t figure our how to do it because ruby treats it  
differently, this is my code:

# request.rxml

xml.instruct! :xml, :version=\>“1.0”, :encoding =\> “UTF-8”  
xml.message {  
xml.access {  
xml.access-code(@access\_code)  
xml.access-pwd(@access\_pass)  
}  
}

which of course doesn’t work because ‘code’ and ‘pwd’ are then treated  
as a separate methods and are not transfered to the method\_missing  
handler in xmlbuilder.

Is there any workaround to this?

---

<div class="post-metadata">

**Author:** ![The\_Cool\_Web\_Guy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/bbe5ce/32.png) [@The\_Cool\_Web\_Guy](https://www.ruby-forum.com/u/The_Cool_Web_Guy)\
**Post date:** [January 25, 2008, 11:46pm UTC](https://www.ruby-forum.com/t/custom-xml-builder-element-needed/126768/2 "2008-01-25T23:46:30Z")

</div>

The Cool Web Guy wrote:

> as a separate methods and are not transfered to the method\_missing  
> handler in xmlbuilder.
> 
> Is there any workaround to this?

According to the Builder-docs tag! should work:

[http://builder.rubyforge.org/classes/Builder/XmlBase.html#M000006](http://builder.rubyforge.org/classes/Builder/XmlBase.html#M000006)
