DOMDocument::loadHTML(): htmlParseEntityRef: expecting ';' in Entity,

简介:
复制代码
$html = file_get_contents("http://www.somesite.com/");

$dom = new DOMDocument();
$dom->loadHTML($html);

echo $dom;
复制代码

THROWS

Warning: DOMDocument::loadHTML(): htmlParseEntityRef: expecting ';' in Entity,
Catchable fatal error: Object of class DOMDocument could not be converted to string in test.php on line 10

(1) calling htmlentities() or similar on the string will fix the problem.

(2)To evaporate the warning, you can use libxml_use_internal_errors(true)

  libxml的链接:http://www.w3school.com.cn/php/php_ref_libxml.asp

From: http://stackoverflow.com/questions/1685277/warning-domdocumentloadhtml-htmlparseentityref-expecting-in-entity


本文转自ZH奶酪博客园博客,原文链接:http://www.cnblogs.com/CheeseZH/p/4858274.html,如需转载请自行联系原作者

相关文章
|
6月前
|
JSON Java 数据格式
Could not extract response: no suitable HttpMessageConverter found for ..content type [text/html...]
Could not extract response: no suitable HttpMessageConverter found for ..content type [text/html...]
658 0
|
JavaScript 前端开发
html、body、document、window 的区别
html、body、document、window 的区别
276 0
html、body、document、window 的区别
HDOJ/HDU 1088 Write a simple HTML Browser(HTML字符串)
HDOJ/HDU 1088 Write a simple HTML Browser(HTML字符串)
106 0
|
JavaScript 容器
HTML-Parser
背景:需求需要把 html 字符串转成 DOM 对象树或者 js 对象树,然后进行一些处理/操作。htmlparser 这个库还行,但是对 attribute 上一些特殊属性值转换不行,同时看了看开标签语法(syntax-start-tag:whatwg)、html-attribute 的支持规则(attributes:whatwg) 和一些其他库的实现,在一些边界场景(特殊属性值和web component)处理还是缺少,算了... 自己撸了个 html parser 的函数么好了。
1012 0
|
Spring Java 安全
Refused to execute script from 'http://127.0.0.1:8004/login' because its MIME type ('text/html') ...
Refused to execute script from 'http://127.0.0.1:8004/login' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled. Refused to execute script …”,为什么会被拒绝执行呢?想到可能是权限的控制问题,亦即是 Spring Security 的静态资源访问配置问题。
3074 0