0

I am using XMLUnit for comparing two XMLs. My requirement is that I want to ignore few attributes of few XML tags while comparing two XMLs. Is there any way to ignore few attributes ?

Thanks in advance.

sameer59
  • 97
  • 11

1 Answers1

0

You could use XPath to transform the XML to strip out the attributes you're not interested in. You could adapt the examples in this thread http://www.actionscript.org/forums/showthread.php3?t=218460

artbristol
  • 32,010
  • 5
  • 70
  • 103
  • Thanks for replying. Actually I have an element which has multiple attributes. I just want to ignore a single attribute while comparing two XMLs. Can this be done ? – sameer59 Apr 12 '12 at 13:28
  • Also is there any way in XMLUnit to get XPath of each element (whether it is a part of Difference object or not). I know that we can get XPath from a Difference object. But I want XPaths of all the elements of the XML file. Is there any way ? – sameer59 Apr 12 '12 at 13:30
  • You can remove a particular attribute by name, if that's good enough. Something like `` (Not quite, because that's for elements not attributes). See http://stackoverflow.com/q/9064951/116509 for the XPaths. – artbristol Apr 12 '12 at 13:43