【发布时间】:2017-02-17 23:48:34
【问题描述】:
下面的代码(使用 CodeIgniter 3.0)给出了这个错误,我不明白为什么:
SimpleXMLElement::__construct():实体:第 1 行:解析器错误:需要开始标记,未找到“
<?php
require_once './pdfGenerator.php';
require_once './pdfWrapper.php';
require_once './tcpdf_ext.php';
$debug = false;
$error_handler = set_error_handler("PDFErrorHandler");
if (get_magic_quotes_gpc()) {
$xmlString = stripslashes($_POST['mycoolxmlbody']);
} else {
$xmlString = $_POST['mycoolxmlbody'];
}
//where the problem
if ($debug == true) {
error_log($xmlString, 3, 'debug_'.date("Y_m_d__H_i_s").'.xml');
}
$xml = new SimpleXMLElement($xmlString, LIBXML_NOCDATA);
$scPDF = new schedulerPDF();
$scPDF->printScheduler($xml);
function PDFErrorHandler ($errno, $errstr, $errfile, $errline) {
global $xmlString;
if ($errno < 1024) {
echo $errstr."<br>";
error_log($xmlString, 3, 'error_report_'.date("Y_m_d__H_i_s").'.xml');
exit(1);
}
}
【问题讨论】:
-
$xmlString 的内容似乎不是有效的 XML。你检查过吗?
-
如果我们要帮助您,您应该向我们提供
$xmlString的内容。但看起来你可以自己解决这个问题