PHP SimpleXML错误

0xm*_*mtn 0 php simplexml

我有一个很大的问题(至少对我而言;))使用SimpleXML解析器.错误是:

Warning: simplexml_load_file(): file.meta:16: parser error : StartTag: invalid element name in index.php on line 89
Warning: simplexml_load_file(): <335> in index.php on line 89
Warning: simplexml_load_file(): ^ in index.php on line 89
Warning: simplexml_load_file(): file.meta:18: parser error : expected '>' in index.php on line 89
Warning: simplexml_load_file(): in index.php on line 89
Warning: simplexml_load_file(): ^ in index.php on line 89
Warning: simplexml_load_file(): file.meta:18: parser error : Opening and ending tag mismatch: Sequence line 15 and unparseable in index.php on line 89
Warning: simplexml_load_file(): in index.php on line 89
Warning: simplexml_load_file(): ^ in index.php on line 89
Warning: simplexml_load_file(): file.meta:19: parser error : StartTag: invalid element name in index.php on line 89
Warning: simplexml_load_file(): <337> in index.php on line 89
Warning: simplexml_load_file(): ^ in index.php on line 89
Warning: simplexml_load_file(): file.meta:21: parser error : expected '>' in index.php on line 89
Warning: simplexml_load_file(): in index.php on line 89
Warning: simplexml_load_file(): ^ in index.php on line 89
Warning: simplexml_load_file(): file.meta:21: parser error : Opening and ending tag mismatch: MetaAttack line 2 and unparseable in index.php on line 89
Warning: simplexml_load_file(): in index.php on line 89
Warning: simplexml_load_file(): ^ in index.php on line 89
Warning: simplexml_load_file(): file.meta:21: parser error : Extra content at the end of the document in index.php on line 89
Warning: simplexml_load_file(): in index.php on line 89
Warning: simplexml_load_file(): ^ in index.php on line 89
Warning: Invalid argument supplied for foreach() in index.php on line 97

我用谷歌搜索但没有得到任何东西.我也搜索了XML标签声明(也许它被禁止声明一个数字标签)但什么也没找到.您可以在下面找到我的xml(.meta)文件:

<?xml version="1.0"?>                                                                                                                                                   
<MA>
    <Count>
        3
    </Count>
    <Duration>
        34
    </Duration>
    <End>
        1315815814
    </End>
    <Start>
        1315815780
    </Start>
    <Sequence>
        <335>
            1315815794
        </335>
        <337>
            1315815814
        </337>
        <336>
            1315815804
        </336>
    </Sequence>
</MA>
Run Code Online (Sandbox Code Playgroud)

在第89行:

$ma = simplexml_load_file("file.meta");
Run Code Online (Sandbox Code Playgroud)

任何答案都表示赞赏.提前致谢.;)

Bil*_*oon 6

在标签名称中使用数字是可以的 - 但从数字开始不行......

http://www.w3schools.com/xml/xml_elements.asp

XML命名规则

XML元素必须遵循以下命名规则:

  • 名称可以包含字母,数字和其他字符
  • 名称不能以数字或标点字符开头
  • 名称不能以字母xml(或XML或Xml等)开头
  • 名称不能包含空格

可以使用任何名称,不保留任何单词.