2014-04-01 2 views
1

일부 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) 도움이되지 않은 사용. 출력 파일에 문서가 생성되었습니다.

+0

무엇'$의 html' 컨텐츠를? – ponciste

+0

죄송합니다. 이전 블록에서 원본 html을 보유하고있는 변수 – DerpyNerd

+0

[this] (http://www.php.net/manual/en/function.libxml-use-internal-errors.php) 아웃. – Passerby

답변

0

서버에서 error_log를 확인 했습니까?

또한, 귀하의 캐치 시도하고 어떻게되는지 :

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

$ ex를 인쇄하면 제안한 방식대로 작동하지 않습니다. 로그로 돌아갑니다. 원격 zend 서버에서 작업 중이므로 아직 확인할 수 없습니다. – DerpyNerd

관련 문제