There is a problem with the xPath search if the str is empty...then it always takes the first...do a validation inside the XmlParser