I'm writing unit tests for code which uses JDOM to read and write XML. I therefore need some way to compare the JDOM Element
being produced by my code with a reference Element
to ensure that they are equivalent (same name, namespace, and attributes, plus the same for its children, recursively).
Unfortunately, Element.equals
only tests whether the elements are referentially equal. How can I best determine whether two elements represent identical trees?