I tesed the code, but it would be very good if you test it also carefully.
To make youe easy to read the code the following comments can be interesting for you.
I made some changes in code of getXmlData which I originally posted. It's small changes in the RegEx (parameter of expr.match) and the last lines of getXmlData. New version of the code is