$code = '
<h1>Galeria </h1>
<div class="galeria">
<ul id="galeria_list">
<li>
<img src="img.jpg" width="350" height="350" />
<br />
Teste
</li>
</ul>
</div>';
$dom = new DOMDocument;
$dom->validateOnParse = true;
$dom->loadHTML($code);
var_dump($dom->getElementById('galeria_list'));
The var_dump
always returns NULL
. Anyone know why? I can clearly see the element with the id galeria_list
in $code
. Why is this not getting the element?
And also, does anyone know how to prevent the domdocument from adding the <html>
and <body>
tags on the saveHTML
method?
Thanks