[Rails] Re: xml question
Nobody Else wrote:
> Does anyone know what the correct way of setting an attribute for an xml
> element is? I know how to do it, but once I try to pass data to it, it
> shows up as an empty element in de outputted xml.
>
> What I have now is the following:
>
> xml.InstdAmt("Ccy" => "EUR") {invoice.sum_after_tax}
>
> Which outputs:
>
> <InstdAmt Ccy="EUR"></InstdAmt>
The block is for adding child elements to an element.
Try this instead:
xml.InstdAmt({ "Ccy" => "EUR" }, invoice.sum_after_tax)
So if, for example the above element was a child of a root element you
might have something like:
xml.RootElement do
xml.InstdAmt({ "Ccy" => "EUR" }, invoice.sum_after_tax)
end
Notice that the block is used to add the child element, which has an
attribute arg (a hash) and a value arg (element contents).
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home