I have a Nokogiri xml node:
node = <word n='ab' v='cd'>something</word>
I want to add an attribute:
node['p']='ef'
but in such a way that it 'shows' the first in the list of attribut开发者_运维问答es, like
node = <word p='ef' n='ab' v='cd'>something</word>
Is there a simple way to do this?
I don't know of any XML serializer that allows you to control the order of attributes (except by accident, relying on undocumented features of a product). It shouldn't matter; the order is only cosmetic.
When you say "the order denotes the certitude" this is very worrying, because you are attaching meaning to the order of attributes when XML is very clear that the order will in general not be maintained. You need to redesign your XML to find a different way to capture this information.
精彩评论