本文介绍了DOMDocument:忽略重复的元素ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-24 19:52