Writing XML Documents

Dear Ruby on Rails Experts,

I’m having difficulties writing XML document. So far i’ve writen it
using rxml.

Here is my rxml file :

 xml.instruct! :xml, :version=>"1.0"
  xml.Order( "xmlns" => 

“urn:oasis:names:specification:ubl:schema:xsd:Order-1.0”,“xmlns:cac” )
do
xml.tag!(“BuyersID”,123)
[1] xml.tag!(“cbc:LineExtensionTotalAmount”,438.50)
xml.tag!(“cbc:IssueDate”,@order_o.delivery.order_date)
xml.tag!(“cac:BuyerParty”) do
xml.tag!(“cbc:Party”) do
xml.tag!(“cbc:PartyName”) do
xml.tag!(“cbc:Name”,@order_o.buyer.name)
end
xml.tag!(“cbc:Address”) do
xml.tag!(“cbc:StreetName”,@order_o.buyer.address)
xml.tag!(“cbc:ContrySubentityCode”,@order_o.buyer.country)
end
xml.tag!(“cbc:Contact”) do
xml.tag!(“cbc:name”,@order_o.buyer.name)
end
end
end
xml.tag!(“cac:SellerParty”) do
xml.tag!(“cbc:Party”) do
xml.tag!(“cbc:PartyName”) do
xml.tag!(“cbc:Name”,@order_o.seller.name)
end
xml.tag!(“cbc:Address”) do
xml.tag!(“cbc:StreetName”,@order_o.seller.address)
xml.tag!(“cbc:ContrySubentityCode”,@order_o.seller.country)
end
end
end
xml.tag!(“cac:Delivery”) do
xml.tag!(“cac:RequestedDeliveryDateTime”,
@order_o.delivery.order_date)
xml.tag!(“cac:DeliveryAddress”) do
xml.tag!(“cbc:StreetName”,@order_o.delivery.address)
xml.tag!(“cbc:BuildingNumber”,"")
xml.tag!(“cbc:ContrySubentityCode”,@order_o.delivery.country)
end
end
xml.tag!(“cac:DeliveryTerms”) do
xml.tag!(“cac:SpecialTerms”,@order_o.delivery.terms)
end
end
end

As you can see at [2], i’m trying to write XML line like this :

<cbc:LineExtensionTotalAmount amountCurrencyCodeListVersionID=“0.3”
amountCurrencyID=“USD”> 438.50 </cbc:LineExtensionTotalAmount>

But so far i can only write like this :

cbc:LineExtensionTotalAmount438.50</cbc:LineExtensionTotalAmount>

Thank You

p.s. Do anyone know an easy example how Ruby on Rails calls
Java/.NET/PHP webservices (other than Ruby) ?

Thank you again :smiley:

Amri H. wrote:

As you can see at [2], i’m trying to write XML line like this :

<cbc:LineExtensionTotalAmount amountCurrencyCodeListVersionID=“0.3”
amountCurrencyID=“USD”> 438.50 </cbc:LineExtensionTotalAmount>

But so far i can only write like this :

cbc:LineExtensionTotalAmount438.50</cbc:LineExtensionTotalAmount>

Thank You

p.s. Do anyone know an easy example how Ruby on Rails calls
Java/.NET/PHP webservices (other than Ruby) ?

Thank you again :smiley:

Hi,

You can try something like this to create attributes:

xml.div( :class=> “leadNotification”)

Thanks,

Michael

Michael M. wrote:

Amri H. wrote:

As you can see at [2], i’m trying to write XML line like this :

<cbc:LineExtensionTotalAmount amountCurrencyCodeListVersionID=“0.3”
amountCurrencyID=“USD”> 438.50 </cbc:LineExtensionTotalAmount>

But so far i can only write like this :

cbc:LineExtensionTotalAmount438.50</cbc:LineExtensionTotalAmount>

Thank You

p.s. Do anyone know an easy example how Ruby on Rails calls
Java/.NET/PHP webservices (other than Ruby) ?

Thank you again :smiley:

Hi,

You can try something like this to create attributes:

xml.div( :class=> “leadNotification”)

Thanks,

Michael

Dear Michael,

Thanx a lot … but can i have an example for this one :smiley: please ? coz
i’m still new in XML writing

Again, Thanx

Dear Michael,

Thanx a lot … but can i have an example for this one :smiley: please ? coz
i’m still new in XML writing

Again, Thanx

Hi Amri,

Try adding that sample to your existing sample. You should end up with
an element called div, with an attribute called class and a value of
that attribute as LeadNotification. You can put other elements inside
of it before you close it out using a standard end statement.

Regards,

Michael