Hi People,
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>
I know for sure the data is there, because when I remove the setting of
the attribute it turns up.
Many thanks,
Danny
--
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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.
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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
That works :) -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.