Xml question

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:

I know for sure the data is there, because when I remove the setting of
the attribute it turns up.

Many thanks,

Danny

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:

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).

That works :slight_smile:

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs