in reply to Comparison of XML files ignoring ordering of child elements

All the replies you have so far assume that you want an error generated if the two documents have the same elements but in a different order:

<root> <data>first</data> <data>second</data> </root>

and

<root> <data>second</data> <data>first</data> </root>

should fail to match. However, although it's not clear, your question implies to me that you would like those two documents to match. That is what XML::SemanticDiff's documentation and name implies to me that it does, but the current version doesn't behave as I would expect. The module's documentation doesn't spell out the er, um, semantics of the comparison process so I suspect my expectations differ from the author's intentions.

The module documentation does suggest the possibility of changing the way detected differences are handled which opens up the possibility that we could put our own spin on the matching process. But there are no examples and, without diving into the module's source code, how the handlers get hooked up is not at all clear.

Bottom line: being very clear about what you mean is important both when asking questions and when documenting code. Well constructed example code and data goes a very long way toward helping with clarity. If what you want is the diff I describe let us know and show us your current test code, because at present that's not the sort of answer you are getting!

Optimising for fewest key strokes only makes sense transmitting to Pluto or beyond

Replies are listed 'Best First'.
Re^2: Comparison of XML files ignoring ordering of child elements
by adikan123 (Novice) on Jan 21, 2019 at 10:19 UTC
    Hello @GrandFather, I agree that my question is not very much precise, I will take care about the points which you have mentioned. The answer posted by Kan is what actually I expect. Expected outcome: The code should compare (ignoring child element's order) 2 XMLs files provided as input to Perl script and also should print the differences along with line numbers. Thanks and Regrads adikan123

      GrandFather already pointed out that if you ignore structural differences (like child ordering) you are after semantic difference(s) between the two files: I haven't looked at the suggested modules, but just reading their names I guess that the one will help you out the most is...I'll let you guess which one ;)