【问题标题】:XML Load File ErrorXML 加载文件错误
【发布时间】:2016-11-09 00:22:39
【问题描述】:

我安装了一个脚本,当我登录到管理仪表板时收到此错误:

警告 (2): simplexml_load_file(): /app/Plugin/PaypalAdaptive/info.xml:7: 解析器错误: xmlParseEntityRef: no name [APP/Controller/PluginsController.php, line 1151]

我检查了文件pluginscontroller.php,这是代码。我是从整个文件的一部分复制过来的。

第 1151 行是:$xml = simplexml_load_file($file);

完整代码从这里开始:

        // get all installed plugins
        $plugins = $this->Plugin->find( 'all', array(
            'order' => 'id DESC'
        ));

        $totalNewVersion = 0;
        if($plugins != null)
        {
            foreach($plugins as $k => $plugin)
            {
                $plugin = $plugin['Plugin'];
                $file = sprintf(PLUGIN_INFO_PATH, $plugin['key']);
                if(file_exists($file))
                {
                    $xml = simplexml_load_file($file);
                    if($xml != null && isset($xml->version))
                    {
                        if((string)$xml->version > $plugin['version'])
                        {
                            $totalNewVersion += 1;
                        }
                    }
                }
            }
        }
        return $totalNewVersion;
    }

    public function admin_do_upgrade( $id )
    {
        if(!$this->Plugin->hasAny(array('id' => $id)))
        {
            $this->Session->setFlash(__('This plugin does not exist'), 'default', array('class' => 'Metronic-alerts alert alert-danger fade in' ));
        }
        else 
        {

【问题讨论】:

标签: php xml parsing


【解决方案1】:

它告诉你 XML 无效,可能是因为它包含一个“&”字符,该字符应该被转义为 &

对任何有缺陷的商品采取您会采取的措施 - 将其寄回供应商并告诉他们进行修复。

【讨论】:

    【解决方案2】:

    我终于解决了,我在代码中进行了一些编辑并使用"&" 而不是"&" 这就是导致问题的原因。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-04-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多