Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/232.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php SimpleXmlElement分析错误_Php_Xml_Wordpress - Fatal编程技术网

Php SimpleXmlElement分析错误

Php SimpleXmlElement分析错误,php,xml,wordpress,Php,Xml,Wordpress,刚刚有一个WordPress网站更新了最新版本。更新后,站点不再加载,我看到以下错误: [27-Jun-2015 06:01:05 UTC] PHP Warning: SimpleXMLElement::__construct(): Entity: line 130: parser error : Opening and ending tag mismatch: wphead line 1 and script in /storage/web/public/sites/www.site.nl/

刚刚有一个WordPress网站更新了最新版本。更新后,站点不再加载,我看到以下错误:

[27-Jun-2015 06:01:05 UTC] PHP Warning:  SimpleXMLElement::__construct(): Entity: line 130: parser error : Opening and ending tag mismatch: wphead line 1 and script in /storage/web/public/sites/www.site.nl/wp-content/themes/site/vihv/control/TControl.php on line 91
[27-Jun-2015 06:01:05 UTC] PHP Warning:  SimpleXMLElement::__construct(): </script> in /storage/web/public/sites/www.site.nl/wp-content/themes/site/vihv/control/TControl.php on line 91
[27-Jun-2015 06:01:05 UTC] PHP Warning:  SimpleXMLElement::__construct():          ^ in /storage/web/public/sites/www.site.nl/wp-content/themes/site/vihv/control/TControl.php on line 91
[27-Jun-2015 06:01:05 UTC] PHP Warning:  SimpleXMLElement::__construct(): Entity: line 148: parser error : Sequence ']]>' not allowed in content in /storage/web/public/sites/www.site.nl/wp-content/themes/site/vihv/control/TControl.php on line 91
第一个错误与此函数有关:

function GetXml() {
            try {
                $Xml = new SimpleXmlElement(TXml::MakeTree($this->GetData(), get_class($this)));
                return $Xml->asXml();
            } catch(Exception $e) {
                //print_r($this->GetData());
            }
        return "<".get_class($this)."/>";
        }
在130号线上我看到

<script type='text/javascript' src='http://www.site.nl/wp-includes/js/underscore.min.js?ver=1.6.0'></script>

可以看到整个文件TControl.php。如何调试此错误?是否可以绕过错误?

自定义联系人表单在CDATA标记中添加了一个JavaScript,注释如下
/*和
/*]>*/
。还有一颗子弹贴着
&bull阻塞了XML解析器。似乎解析器不喜欢这样注释CDATA。
为了调试,我从另一个使用

print("<pre>");
var_dump($this->GetData());
libxml_use_internal_errors(true);
echo 'Caught exception: ', $e->getMessage(), "\n";
print($xml);
die();
如果一切正常,打印错误或XML。使用调整后的TConfig功能

$xml=$TXml->MakeTree($this->GetData(),get_class($this));
#$xml=str_replace(“,”-“,$xml);
#$xml=preg\u replace(“@/\*.*/@”,”,$xml);
$xml=preg\u replace(“@/\*.*/@”,”,$xml);
$Xml=新的simplexmlement($Xml);
返回$Xml->asXml();
}捕获(例外$e){
打印(“”);
var_dump($this->GetData());
libxml\u使用\u内部错误(true);
回显“捕获的异常:”,$e->getMessage(),“\n”;
打印(xml);
模具();

一切都恢复正常。Preg replace用于删除有问题的CDATA代码。将在稍后阶段查看它是否可以在没有
/**/

的情况下继续使用。请阅读此处,使用print\r进行调试不是一个好主意。将查看我是否可以实现他们的建议,但仍希望听到其他人的建议和绕过的选项错误。事实上,问题似乎来自simpleXMLelement类的uu construct()方法。你能在回答中包含该方法吗?就调试而言,获取PHPStorm…你不会回头看!当我运行站点时,插件打开时,使用
echo'catched exception:',$e->getMessage(),“\n”
此处建议:我看到了
捕获的异常:字符串无法解析为XML捕获的异常:字符串无法解析为XML捕获的异常:字符串无法解析为XML
没有足够的帮助..在CCF上打开了一个问题,询问自定义联系人表单在主页等页面中添加了什么,以确定是否添加了无效代码以及添加了什么添加了无效代码。
function __construct() {
        $Manager = TEventManager::getInstance();
        $Manager->AddListener($this);
        $this->SetEvent('OnGet', array($this,'OnGetEvent'));
        $this->SetEvent('OnPost', array($this,'OnPostEvent'));
        $this->SetEvent('OnDisplay', array($this,'OnDisplayEvent'));
        $this->SetEvent('OnBeforeDisplay', array($this,'OnBeforeDisplayEvent'));
        $this->SetEvent('OnEnable', array($this,'OnEnableEvent'));
        $this->SetEvent('OnDisable', array($this,'OnDisableEvent'));
        $this->SetEvent('OnCreate', array($this,'OnCreateEvent'));
        $this->SetEvent('OnRootTemplateLoad', array($this,'OnRootTemplateLoadEvent'));
        $this->SetEvent('OnDefaultPage', array($this,'OnDefaultPageEvent'));
        $this->OnCreate($this);
        }
print("<pre>");
var_dump($this->GetData());
libxml_use_internal_errors(true);
echo 'Caught exception: ', $e->getMessage(), "\n";
print($xml);
die();
$xml = file_get_contents("qqq.xml");
$xml = str_replace("", "X", $xml);
$xml = preg_replace("@/\*.*\*/@", "", $xml);
$rr = simplexml_load_string($xml);
var_dump($rr);
$xml = $TXml->MakeTree($this->GetData(), get_class($this));
#$xml = str_replace("", "-", $xml);
#$xml = preg_replace("@/\*.*\*/@", "", $xml);
$xml = preg_replace("@/\*.*\*/@", "<!-- commented out -->", $xml);
                $Xml = new SimpleXmlElement($xml);
                return $Xml->asXml();
            } catch(Exception $e) {
print("<pre>");
var_dump($this->GetData());
libxml_use_internal_errors(true);
echo 'Caught exception: ',  $e->getMessage(), "\n";
print($xml);
die();