Updated XML parsing to handle invalid responses containing trailing
spaces.