Loading ...
Sorry, an error occurred while loading the content.

753Re: Re: [id-ruby] Writing XML Documents

Expand Messages
  • Amri Hidayat
    Sep 1, 2006
      Makaci banyak nya :D

      On 9/2/06, Ahmad Dendi Dwipayana <ahmad.dendi@...> wrote:
      >
      >
      >
      >
      >
      >
      > iseng-iseng coba di ruby, tapi pake builder,
      > ini kodenya :
      > ----
      > require 'builder'
      > xml = ''
      > doc = Builder::XmlMarkup.new(:target => xml, :indent =>2)
      > doc.instruct!
      > doc.Order(:xmlns=>'urn:oasis:names:specification:ubl:schema:xsd:Order-1.0'){|Order|
      > Order.BuyersID("123")
      > Order.tag!:cbc,:LineExtensionTotalAmount,
      >
      > :amountCurrencyCodeListVersionID=>"0.3", :amountCurrencyID=>"USD",*438.50
      > }
      > puts xml
      > ----
      > hasilnya :
      >
      > <?xml version="1.0" encoding="UTF-8"?>
      >
      > <Order xmlns="urn:oasis:names:specification:ubl:schema:xsd:Order-1.0">
      > <BuyersID>123</BuyersID>
      >
      > <cbc:LineExtensionTotalAmount amountCurrencyCodeListVersionID="0.3"
      > amountCurrencyID="USD">438.5</cbc:LineExtensionTotalAmount>
      > </Order>
      >
      > tentang builder <http://builder.rubyforge.org/>
      > http://www.xml.com/lpt/a/1637(Creating XML with Ruby and Builder)
      > -dendi-
      >
      >
      > Amri Hidayat wrote:
      > >
      > > 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 [1], 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:LineExtensionTotalAmount>438.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 :D
      > >
      > > __._,_
      >
      >
      >
      >
    • Show all 7 messages in this topic