Tidy - How to remove duplicate ID from HTML

I have HTML that needs to be parsed using DOMDocument::loadHtml($html), but it gives me an error:

DOMDocument::loadHTML(): ID 'my id' already defined in Entity

I have no control over it $html, but I can use tidy lib (or something else, ideas?) On it and make parsed HTML. But I do not find the option in a neat configuration to remove the duplicate ID in the confid. My code is as follows:

$tidy = new tidy();
$tidy->parseString($this->getPageContents());
$html = new DOMDocument();
$html->loadHTML($tidy); // error here

thank

+3
source share
1 answer

to try

$html->loadXML($tidy);

and rewrite the id with xml dom before parsing as html dom

0
source

All Articles