整洁 - 如何从HTML中删除重复的ID

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

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

I don't have control about the $html, but I can use tidy lib (or something else, ideas?) on it and make a parseable HTML. But I'm not finding a option in tidy's config to remove duplicate ID's in tidy config. My code is like that:

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

Thx

try

$html->loadXML($tidy);

and than rewriting the id's using xml dom before parsing as html dom