DOMDocument loadHTML 函数失败


DOMDocument loadHTML function fails

我正在尝试将一些html加载到DOMDocument中,但我无法正确调试它。

这是原始(未格式化)HTML 字符串:

<html><head><title>Pagina 1</title>
<link rel='stylesheet' href='/css/SxCms.css' type='text/css'></head><body>
<div id='editorWrapper' style='postion: relative; z-index: 1; width:1600 height: 1131px;'>
<img id='editingImage' src='/img/briefingStartP-Stages2013-2014.pdf/briefingstartp-stages2013-2014_1395824936_1.jpg' /></div></body></html>

这就是我加载它的方式(简单明了):

    try {
        libxml_use_internal_errors(true);
        $doc = new DOMDocument();
        file_put_contents('output.txt', 'doc created');
        if (!$doc->loadHTML($html)) {
            file_put_contents('output.txt', "loadfails: ".libxml_get_errors());
            libxml_clear_errors();
        }
    } catch (Exception $ex) {
        file_put_contents('output.txt', "failed: $ex");
    }
输出

中的最后一个输出.txt是"文档创建"。我应该看到一个例外吧?

任何帮助都值得赞赏:)

编辑使用libxml_use_internal_errors(true)没有帮助。我仍然在我的输出文件中创建了文档。

您是否检查了服务器上的error_log?

另外,尝试,在你的捕获中,看看会发生什么:

file_put_contents('output.txt', "failed: ". print_r($ex, true));