Not surprised. As someone already suggested use Data::Dumper to understand the differences in the data structures ($data). The 2 versions of the XML document are not same, so it is only natural that the data structures generated will not be the same either.