I recently dealt with an API that requires the nodes of an XML document to be in a specific order. I was wondering why they feel the need to provide this when I cannot find absolutely no reason why everything should be so.
For intance, this will be correct (xml is greatly simplified)
<transaction> <address>1 main st</address> <amount>100</amount> <orderId>1234</orderId> </transaction>
but it will return an error
<transaction> <address>1 main st</address> <orderId>1234</orderId> <amount>100</amount> </transaction>
At first it seemed to me that they can store things in the form of a list / array, and indexes always refer to the same node. I understand why sending host nodes having the same name in the same order is important as described in this question . However, some nodes may be omitted:
<transaction> <amount>100</amount> <orderId>1234</orderId> </transaction>
So, in the third example, the quantity and order will now be in [0] and [1] instead of [1] and [2] in the first (correct) example.
Another thought would be that they treat XML as a string and require that they always know that nodes come one after another, but again, since nodes can be deleted, this theory makes no sense.
Can someone explain to me why the order in which I give the nodes matters? Or am I just dealing with an API that is old and grumpy?
source share