2009-12-11 27 views

回答

2
xml.tag!(col.to_s_upcase, self[col]) 

xml.instruct! :xml, :version=>"1.0", :encoding=>"UTF-8" 
for col in [:customer, :name, :address, :city, :street, :postal_code] 
    eval("xml.#{col.to_s.upcase}(#{self[col]})") 
end 

此代碼顯然,如果有一個「或」自我[COL]我也寧願不使用eval我已經嘗試不起作用

0
xml.tag!(element_name, element_value)