1<?php
2$xmls = array(
3    '<?xml version="1.0"?><element>',
4    '<?xml>',
5    '<?xml version="dummy">',
6    '<?xml?>',
7    '<?xml version="1.0"?><elem></element>',
8);
9
10foreach ($xmls as $xml) {
11    $xml_parser = xml_parser_create();
12    if (!xml_parse($xml_parser, $xml, true)) {
13        var_dump(xml_get_error_code($xml_parser));
14        var_dump(xml_error_string(xml_get_error_code($xml_parser)));
15    }
16    xml_parser_free($xml_parser);
17}