B
Brad Symons
Hi,
I am just trying to understand how builder sorts the content of an xml
node, because no matter how I arrange the options, they appears sorted
differently in the irb.
ids = ["1","2","3"]
alphas = ["xxx","yyy","zzz"]
xml = Builder::XmlMarkup.new( :target => $stdout, :indent => 2 )
xml.instruct! :xml, :version => "1.1", :encoding => "US-ASCII"
ids.each do |num|
xml.programmealpha => alphas.fetch(ids.index(num)), :id => num)
end
This prints:
<programme alpha="xxx" id="1"/>
<programme alpha="yyy" id="2"/>
<programme alpha="zzz" id="3"/>
But if I re-arrange the positioning to:
xml.programmeid => num, :alpha => alphas.fetch(ids.index(num)))
It still produces:
<programme alpha="xxx" id="1"/>
<programme alpha="yyy" id="2"/>
<programme alpha="zzz" id="3"/>
NO CHANGE!!!
Also, is there an easy way to map the values of the arrays together,
than using the fetch method?
THANKS IN ADVANCE!!
I am just trying to understand how builder sorts the content of an xml
node, because no matter how I arrange the options, they appears sorted
differently in the irb.
ids = ["1","2","3"]
alphas = ["xxx","yyy","zzz"]
xml = Builder::XmlMarkup.new( :target => $stdout, :indent => 2 )
xml.instruct! :xml, :version => "1.1", :encoding => "US-ASCII"
ids.each do |num|
xml.programmealpha => alphas.fetch(ids.index(num)), :id => num)
end
This prints:
<programme alpha="xxx" id="1"/>
<programme alpha="yyy" id="2"/>
<programme alpha="zzz" id="3"/>
But if I re-arrange the positioning to:
xml.programmeid => num, :alpha => alphas.fetch(ids.index(num)))
It still produces:
<programme alpha="xxx" id="1"/>
<programme alpha="yyy" id="2"/>
<programme alpha="zzz" id="3"/>
NO CHANGE!!!
Also, is there an easy way to map the values of the arrays together,
than using the fetch method?
THANKS IN ADVANCE!!