Fix errors when xml is in a wrong format