Brandon
(Brandon)
1
I am using the XML builder and I am frustrated by the lack of being
able to use variables to define the names of XML elements
I want to be able to do this (in actionname.xml.builder)
...
element_name = "Tag"
xml.element_name("Brandon")
...
ACTUAL OUTPUT
...
<element_name>Brandon</element_name>
...
DESIRED OUTPUT
...
<Tag>Brandon</Tag>
...
Does anyone know how I could achieve the desired output using only the
xml builder?
have a look at the tag! method
Fred
Ajit
(Ajit)
3
try
xml.instruct!
xml.data do
xml.tag "Brandon"
end
this will give you:
<data>
<tag>Brandon</tag>
</data>
Cheers
GGC
(GGC)
4
LOL, much easy, i think so
Happy coding.
Try using "send" to send the element name. So
element_name = :tag
xml.send(element_name) "Brandon"
11155
(-- --)
6
bensomers wrote:
Try using "send" to send the element name. So
element_name = :tag
xml.send(element_name) "Brandon"
thanx for your help. It was really helpful
how can I add attribute. I want in this format
<count date="20050412T00:00:00">214</count>
how can I add attribute date.
xml.count(:date=>service.date, service.code)
^ ^ ^
dot tag hash = attribute no hash = inner value