Welcome to the Monastery. If you want to be able to find out which files have non-empty "fail-message" elements, so that you can see how many different values there are for fail messages, you probably want to use XPath expressions (which you can look up elsewhere - it's not strictly a Perl thing).
in reply to parsing xml
For example, a while back I figured out how to use the XPath facilities in XML::LibXML, and it was so easy and so cool, I posted some sample code for a generic tool to take an XPath expression and an XML file as command-line args, and output the portions of a given file (if any) that matched a given XPath: Re: XPath command line utility....
Consider a sample XML file like this (let's call this file "test.xml"):
If I want to extract non-empty "fail-message" elements from that sort of XML data, the XPath expression would be:
To apply that expression using my "exp" tool, the (bash) command line would be:
Since I might want to see all the markup (including attributes) for nodes that match the expression, I included a '-x' option on my "exp" script to do just that. In this case, seeing the markup would be helpful if I want to look at the empty fail-messages (by using "=" instead of "!=" in the XPath expression).
exp -p "//*[fail-message!='']" test.xml