Use a module like XML::Simple to slurp the file into a hashref. Then loop through the hashref checking for the "x" value. If you don't know what the hashref will look like, use Data::Dumper to print it out so you can figure out how to loop through it.
-imran