PHP Dom not retrieving element

前端 未结 4 417
旧时难觅i
旧时难觅i 2021-01-14 23:45
$code = \'

Galeria

4条回答
  •  清酒与你
    2021-01-15 00:24

    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'));

提交回复
热议问题