问题描述
我正在使用DOMDocument::loadHTML
将一些页面内容(已经通过Tidy运行,但是如果这是问题的源头,则不需要这样做).
I'm putting some page content (which has been run through Tidy, but doesn't need to be if this is a source of problems) into DOMDocument
using DOMDocument::loadHTML
.
出现各种错误:
是否有任何方法可以使DOMDocument
(或Tidy)忽略或去除重复的元素ID,因此它实际上会创建DOMDocument
吗?
Is there any way to make either DOMDocument
(or Tidy) ignore or strip out duplicate element IDs, so it will actually create the DOMDocument
?
谢谢. :)
推荐答案
快速搜索该主题会发现以下(错误的)错误报告:
A quick search on the subject reveals this (incorrect) bug report:
http://bugs.php.net/bug.php?id=46136
最后一个答复指出:
由于相同的原因,我不确定您是否遇到此问题,因为您没有包括对正在加载的HTML页面的引用.无论如何,都应使用 libxml_use_internal_errors()
至少抑制错误.
I can't be sure if you are encountering this problem for the same reasons, since you did not include a reference to the HTML page being loaded. In any case, using libxml_use_internal_errors()
should at least suppress the error.
ID 通常是唯一的,因此,最佳解决方案将尽可能地验证您的文档.
ID's in HTML documents are generally unique, so the best solution would still be validating your document, if at all possible.
这篇关于DOMDocument:忽略重复的元素ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!