tags:

views:

49

answers:

1

Is there a way to generate xml tags with dashes in builer?

Imagine I want to generate the following XML:

<ninja-programmer>
    Jon Skeet
</ninja-programmer>

I am not able to do it like:

require 'builder'
data = ''
x = Builder::XmlMarkup.new(:target => data, :indent => 2)
x.instruct!
x.ninja-programmer "Jon Skeet"

That would confuse the parser so, how can I do it?

Thanks

+2  A: 

Try declaring it explicitly:

x.tag! "ninja-programmer", "Jon Skeet"

There is a funky way too:

x.send :"ninja-programmer", "Jon Skeet"
floatless