As formatted, your data is hard to understand. I tried to make it presentable using 2 tools (XML::Tidy and xmllint), but both returned errors.
Therefore, I will only offer the general advice to use an XML parser. I have been happy with XML::Twig. It has a tutorial, and there are many code examples here at the Monastery (and elsewhere).