我发现了几个类似的问题,但到目前为止,没有一个能够帮助我。
我正在尝试在 HTML 块中输出所有图像的“src”,所以我正在使用DOMDocument()
. 这种方法确实有效,但我在某些页面上收到警告,我不知道为什么。一些帖子建议隐藏警告,但我更愿意找出生成警告的原因。
警告:DOMDocument::loadHTML(): htmlParseEntityRef:实体中没有名称,行:10
产生错误的一个例子post->post_content
是 -
On Wednesday 21st November specialist rights of way solicitor Jonathan Cheal of Dyne Drewett will be speaking at the Annual Briefing for Rural Practice Surveyors and Agricultural Valuers in Petersfield.
<br>
Jonathan is one of many speakers during the day and he is specifically addressing issues of public rights of way and village greens.
<br>
Other speakers include:-
<br>
<ul>
<li>James Atrrill, Chairman of the Agricultural Valuers Associates of Hants, Wilts and Dorset;</li>
<li>Martin Lowry, Chairman of the RICS Countryside Policies Panel;</li>
<li>Angus Burnett, Director at Martin & Company;</li>
<li>Esther Smith, Partner at Thomas Eggar;</li>
<li>Jeremy Barrell, Barrell Tree Consultancy;</li>
<li>Robin Satow, Chairman of the RICS Surrey Local Association;</li>
<li>James Cooper, Stnsted Oark Foundation;</li>
<li>Fenella Collins, Head of Planning at the CLA; and</li>
<li>Tom Bodley, Partner at Batcheller Monkhouse</li>
</ul>
post->post_content
如果有帮助,我可以发布更多包含内容的示例?
我已暂时允许访问开发站点,因此您可以查看一些示例 [注意 - 问题已得到解答,链接不再可访问] -
- 错误 - http://test.dynedrewett.com/specialist-solicitor-speaks-at-petersfield-update/
- 没有错误 - http://test.dynedrewett.com/restrictive-covenants-in-employment-contracts/
有关如何解决此问题的任何提示?谢谢。
$dom = new DOMDocument();
$dom->loadHTML(apply_filters('the_content', $post->post_content)); // Have tried stripping all tags but <img>, still generates warning
$nodes = $dom->getElementsByTagName('img');
foreach($nodes as $img) :
$images[] = $img->getAttribute('src');
endforeach;