일부 HTML을 DOMDocument로로드하려고하는데 올바르게 디버깅 할 수 없습니다.DOMDocument loadHTML 함수가 실패합니다.
이 원래 (포맷되지 않은) 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>
그리고 이것이 내가 (일반 및 simpel)를로드하는 방법입니다
이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");
}
경우 output.txt의 마지막 출력은 ' doc created '. 예외적으로보아야합니까?
어떤 도움에 감사드립니다 :)
편집 libxml_use_internal_errors(true)
도움이되지 않은 사용. 출력 파일에 문서가 생성되었습니다.
무엇'$의 html' 컨텐츠를? – ponciste
죄송합니다. 이전 블록에서 원본 html을 보유하고있는 변수 – DerpyNerd
[this] (http://www.php.net/manual/en/function.libxml-use-internal-errors.php) 아웃. – Passerby