You can achieve this easily by playing with data structures like hash of hashes. You can match where key H4 equals to "include" and by iterating loop you can count L1 elements.
Or you can use "XML::Simple" module. and using "$xs->XMLin($xml);" will give you more readable form of your data.
I hope that would be easy.
Comment on Re: Counting number of child nodes based on element value