0

I have similar issues as were already discussed here: Xml Serialization Sequence Issue

As I understand that I could fix this issue by using the "order" attribute - I'm wondering why this happens at all!? It seems to me that the serialization result somehow is "random" - 10x you get the one sequence then you get a couple of times an other sequence. It also seems that the sequence is not completely random - but (at least for my case) only the first two elements are randomly mixed ...

Does anyone have a good explanation for that?

Community
  • 1
  • 1

1 Answers1

0

Not sure what implementation you refer to, but my bet would be that the tree is internally organised/represented as hash-map (element -> node) or some other similarly non-order-preserving data structure.

Doing that obviously facilitates XPath-like lookups at the cost of, well you noticed, preserving the order of the elements/attributes. I'm sure the XML library you use provides settings to tune (or turn off) that behaviour but without further detail it's all a guess.

hroptatyr
  • 4,702
  • 1
  • 35
  • 38
  • hi - I'm using Microsofts standard .net xml serialization classes (.net 3.5) ... what mainly puzzels me is that the serialized xml result is not predictable - i had expected that the serializor works always the same ... – Josef.Semmler Mar 22 '12 at 09:29