From: Stefan B. <bo...@ap...> - 2007-11-16 14:57:19
|
On Fri, 16 Nov 2007, vamsidhar sharma <bva...@ya...> wrote: > Hi xmlunit users, > > Had a question regarding the behaviour of XMLUnit in the below > scenario: > > Control Doc = > <div class="main"> > <x/> > <a href="1232"/> > <div class="top">top</div> > <div class="bottom">bottom</div> > </div> > > Test Doc = > <div class="main"> > <a href="123"/> > <div class="top">top</div> > <div class="bottom">bottom</div> > </div> > > Looking at the docs. it is clear that 'x' tag is missing in test > doc. Below is the report that XMLUnit that is generated. > From 2nd line I could infer that 'x' is missing element. > However, when control reaches 'a' in control doc. it is compared > with 'div' in test doc. By default XMLUnit matches each node in the control document against the node that appears "at the same place" in the test document. What you want is that XMLUnit compares elements with the closest element that has the same name. To achieve that, you want to use an ElementNameQualifier, see <http://xmlunit.sourceforge.net/userguide/html/ar01s03.html#ElementQualifier>. Stefan |