0
我想產生這樣的xml:構建在Ruby中被添加<xml/>到標記>
<ns1:type>Account</ns1:type>
<ns1:ids>2c92c0f83d60e055013d859f7f4873ee</ns1:ids>
<ns1:ids>2c92c0f83d60e055013d859f7f2f73ec</ns1:ids>
我使用這個代碼:
def generate_id_xml
xml = Builder::XmlMarkup.new
xml.__send__(self.ons, :type, self.remote_name)
objects.each do |o|
xml.__send__(self.ons, :ids, o.id)
end
xml.xml
end
但它是生產:
<ins1:type>Account</ins1:type>
<ins1:ids>2c92c0f93d60e66d013d83e5845e04bc</ins1:ids
<ins1:ids>2c92c0f93d60e66d013d83e5847904be</ins1:ids>
<xml/>
爲什麼它添加了xml /有沒有辦法擺脫它?
我有這個代碼,它沒有添加xml /標籤到它的輸出。
def generate_xml
xml = Builder::XmlMarkup.new
objects.each do |o|
generate_object xml, o
end
xml.xml
end
#generate xml for an object
def generate_object(builder, object)
builder.__send__(self.zns, :zObjects, 'xsi:type' => "ins1:#{self.remote_name}") do |a|
object.to_hash.each do |k,v|
a.__send__(self.ons, k.to_s.zuora_camelize.to_sym, v) unless v.nil?
end
end
end
我也剛剛注意到,第一行ID缺少> endtag。 – user2183651 2013-03-20 03:48:51