$code = \'
Galeria
-
It seems that loadhtml() does not "attach" the html dtd that defines id
as an id-attribute to the DOM. But if the html document contains a DOCTYPE declaration it works as intended. (But my guess is you don't want to add a doctype and html skeleton, anyway:).
$code = '
...
Galeria
-
Teste
';
$dom = new DOMDocument;
$dom->loadhtml($code);
var_dump($dom->getElementById('galeria_list'));