improved XML format detection