Hello all, and apologies for any crossposts. I thought this might be
relevant to a number of development communities, and it may be that you're
subscribed to more than one fo them.
In the course of writing spec tests to compare actual serialized XML output
to expected XML output, I became somewhat dissatisfied with the existing
options I found. Straight text comparisons are brittle for a number of
reasons. xml-simple's comparison functionality lacked some of what I was
looking for. nokogiri-diff (which Chris Beer brought to my attention
yesterday) is less of a true/false turnkey solution than I wanted it to be.
So I holed up for a few hours and knocked out equivalent-xml:
Usage is simple. Pass it two XML (currently, but not by design,
Nokogiri-specific) nodes, and it tells you whether the two are equivalent
based on a few rules, which are outlined in the README. The flexibility
comes from its ability to (optionally) ignore the order of child elements,
because sometimes you just don't care, and also to (optionally) normalize
whitespace within text nodes before comparing them.
If you find it useful, I'd love to hear about it. And if you think it could
use improvement, I welcome both suggestions and pull requests.