in reply to Re: XML::Smart - Development in final stage. (beta is out)
in thread XML::Smart - Development in final stage. (beta is out)

Yes, it keeps the order! Note that you actually have a HASH tree inside the object, that have your XML data, exatcly like XML::Simple. When you have multiples nodes, they are inside an array, and if you have a key, and add a new node, this key is converted to an array, with the previous key as the first.

The only order that is changed is the order of arguments in the tag. What I don't know if can make changes in the use of XML.

Graciliano M. P.
"The creativity is the expression of the liberty".

  • Comment on Re: Re: XML::Smart - Development in final stage. (beta is out)

Replies are listed 'Best First'.
Re: Re: Re: XML::Smart - Development in final stage. (beta is out)
by diotalevi (Canon) on May 13, 2003 at 16:34 UTC

    Yes, it keeps the order!
    The only order that is changed is the order of arguments in the tag. What I don't know if can make changes in the use of XML.
    I don't know the difference between the two orders you specified. Can you be clearer about which order is kept and which is not? Most likely the only order in question is sibling element order which is what I'm stating is critical and is also what is thrown away by many of the other XML->perl hash translations out there.

      If you have this in the original XML:
      <foo cc="1" bb="2" aa="3"/>
      When you rewrie the XML you got:
      <foo aa="3" bb="2" cc="1"/>
      This hapens because the keys in the hash doesn't have order, soo I sort it.

      But if you have:

      <foo> <i>zzz</i> <i>xxx</i> <i>www</i> </foo>
      The order of the multiple 'i' isn't changed.

      What I don't know is if the 1st type, where the order is changed, make difference in the DTD, since I'm not a XML geek. If the order for the arguments in the tag is really needed, I can make XML::Smart care with the order of the keys, but this will consume more memory and CPU.

      Graciliano M. P.
      "The creativity is the expression of the liberty".

        I'm not aware of attribute order ever being a concern. Element order always is so in the following code, you must always reconstruct it in this order. The two identically named elements may remain in order though DTD doesn't require it. The other sibling elements D and C must remain in exactly that order - perl's hash order cannot be allowed to disturb that. All in all, I think you'll find that Tie::HashIx is useful for this. If you don't intend on producing validatable XML then this requirement isn't important - your call.

        <a> <d>e</d> <b>a</b> <b>b</b> <c>c</c> </a>