simplexml_load_file中的错误

时间:2013-08-23 18:39:20

标签: php simplexml

我有几个错误

[23-Aug-2013 15:35:20 America/Sao_Paulo] PHP Warning:  simplexml_load_file() [<a href='function.simplexml-load-file'>function.simplexml-load-file</a>]: /home/lineage/public_html/acp/xml/banners.xml:48: parser error : Opening and ending tag mismatch: banner line 33 and list in /home/lineage/public_html/acp/core.php on line 191
[23-Aug-2013 15:35:20 America/Sao_Paulo] PHP Warning:  simplexml_load_file() [<a href='function.simplexml-load-file'>function.simplexml-load-file</a>]: &lt;/list&gt; in /home/lineage/public_html/acp/core.php on line 191
[23-Aug-2013 15:35:20 America/Sao_Paulo] PHP Warning:  simplexml_load_file() [<a href='function.simplexml-load-file'>function.simplexml-load-file</a>]:        ^ in /home/lineage/public_html/acp/core.php on line 191
[23-Aug-2013 15:35:20 America/Sao_Paulo] PHP Warning:  simplexml_load_file() [<a href='function.simplexml-load-file'>function.simplexml-load-file</a>]: /home/lineage/public_html/acp/xml/banners.xml:48: parser error : Premature end of data in tag banner line 26 in /home/lineage/public_html/acp/core.php on line 191
[23-Aug-2013 15:35:20 America/Sao_Paulo] PHP Warning:  simplexml_load_file() [<a href='function.simplexml-load-file'>function.simplexml-load-file</a>]: &lt;/list&gt; in /home/lineage/public_html/acp/core.php on line 191
[23-Aug-2013 15:35:20 America/Sao_Paulo] PHP Warning:  simplexml_load_file() [<a href='function.simplexml-load-file'>function.simplexml-load-file</a>]:        ^ in /home/lineage/public_html/acp/core.php on line 191
[23-Aug-2013 15:35:20 America/Sao_Paulo] PHP Warning:  simplexml_load_file() [<a href='function.simplexml-load-file'>function.simplexml-load-file</a>]: /home/lineage/public_html/acp/xml/banners.xml:48: parser error : Premature end of data in tag banner line 19 in /home/lineage/public_html/acp/core.php on line 191
[23-Aug-2013 15:35:20 America/Sao_Paulo] PHP Warning:  simplexml_load_file() [<a href='function.simplexml-load-file'>function.simplexml-load-file</a>]: &lt;/list&gt; in /home/lineage/public_html/acp/core.php on line 191
[23-Aug-2013 15:35:20 America/Sao_Paulo] PHP Warning:  simplexml_load_file() [<a href='function.simplexml-load-file'>function.simplexml-load-file</a>]:        ^ in /home/lineage/public_html/acp/core.php on line 191
[23-Aug-2013 15:35:20 America/Sao_Paulo] PHP Warning:  simplexml_load_file() [<a href='function.simplexml-load-file'>function.simplexml-load-file</a>]: /home/lineage/public_html/acp/xml/banners.xml:48: parser error : Premature end of data in tag list line 2 in /home/lineage/public_html/acp/core.php on line 191
[23-Aug-2013 15:35:20 America/Sao_Paulo] PHP Warning:  simplexml_load_file() [<a href='function.simplexml-load-file'>function.simplexml-load-file</a>]: &lt;/list&gt; in /home/lineage/public_html/acp/core.php on line 191
[23-Aug-2013 15:35:20 America/Sao_Paulo] PHP Warning:  simplexml_load_file() [<a href='function.simplexml-load-file'>function.simplexml-load-file</a>]:        ^ in /home/lineage/public_html/acp/core.php on line 191
[23-Aug-2013 15:35:20 America/Sao_Paulo] PHP Notice:  Trying to get property of non-object in /home/lineage/public_html/acp/core.php on line 206
[23-Aug-2013 15:35:20 America/Sao_Paulo] PHP Warning:  Invalid argument supplied for foreach() in /home/lineage/public_html/acp/core.php on line 197

我采用了这个系统,但它不知道它发生了什么!

行:197 core.php

foreach ($this->getAll() as $banner) { 

行:191 core.php

$_xmlBanners = simplexml_load_file(PATH_XML."banners.xml");

Baners.xml:

<?xml version="1.0" encoding="UTF-8"?>
<list>
    <banner id="1">
        <image>http://lineagefree.com/acp/images/l2jbr.png</image>
        <link>http://l2j.lt/topai/balsuoti-7907.php</link>
        <votes>
            <link>http://l2j.lt/topai/mokamas-7907.php</link>
            <regexp><div class='list_8' style="font-weight: bold">(.*)</div></regexp>
        </votes>
    </banner>
    <banner id="2">
        <image>http://lineagefree.com/acp/images/top100mmorpg.png</image>
        <link>http://l2j.lt/topai/balsuoti-7907.php</link>
        <votes>
            <link>http://l2j.lt/topai/mokamas-7907.php</link>
            <regexp><div class='dlist_8' style="font-weight: bold">(.*)</div></regexp>
        </votes>
    </banner>
    <banner id="3">
        <image>http://lineagefree.com/acp/images/gamesitestop100.jpg</image>
        <link>http://l2j.lt/topai/balsuoti-7907.php</link>
        <votes>
            <link>http://l2j.lt/topai/mokamas-7907.php</link>
            <regexp><div class='dlist_8' style="font-weight: bold">(.*)</div></regexp>
        </votes>
        <banner id="4">
        <image>http://lineagefree.com/acp/images/arenatop100.png</image>
        <link>http://l2j.lt/topai/balsuoti-7907.php</link>
        <votes>
            <link>http://l2j.lt/topai/mokamas-7907.php</link>
            <regexp><div class='dlist_8' style="font-weight: bold">(.*)</div></regexp>
        </votes>
        <banner id="5">
        <image>http://lineagefree.com/acp/images/mmorpglist.jpg</image>
        <link>http://l2j.lt/topai/balsuoti-7907.php</link>
        <votes>
            <link>http://l2j.lt/topai/mokamas-7907.php</link>
            <regexp><div class='dlist_8' style="font-weight: bold">(.*)</div></regexp>
        </votes>
        <banner id="6">
        <image>http://lineagefree.com/acp/images/top200.gif</image>
        <link>http://l2j.lt/topai/balsuoti-7907.php</link>
        <votes>
            <link>http://l2j.lt/topai/mokamas-7907.php</link>
            <regexp><div class='dlist_8' style="font-weight: bold">(.*)</div></regexp>
        </votes>
    </banner>
</list>

跟随所有数据。如果您还需要,请问我。 我很绝望。 对不起我的英文。用谷歌完成了!

1 个答案:

答案 0 :(得分:1)

错误消息Opening and ending tag mismatch: banner line 33 and list告诉您,在解析XML文件时,解析器找到了一个开始标记<banner>,然后是一些嵌套内容,但是当它期望匹配的结束标记{{ 1}}它找到了一个不同的结束标记</banner>

当你在某个地方打开一个永远不会关闭的标记时,通常就会发生这种情况,这意味着解析器在某些外部块关闭时仍在等待你关闭它。

在这种情况下,您可以查看XML并查看有6个开放的</list>标记,但只有3个关闭<banner>,因此显然出现了问题。

事实上,您似乎错过了ID为3,4和5的横幅末尾的</banner>