etree: handle invalid xml

Change-Id: I061e2f2db93b81a8a59a7a968bb59b58bce91717