I am creating an element with this code. Setting the ID as it should be set. (Do I need the validateonparse?):
$sectionContainer = $dom->createElement('div', $section);
$sectionContainer->setAttribute("id", $section);
$sectionContainer->setIdAttribute("id", TRUE);
$dom->validateOnParse = true;
$divup->parentNode->insertBefore($sectionContainer, $divup);
echo 'avant'."</br>";
echo $section;
print_r($dom->getElementById($section)->getAttribute('id'));
echo 'apres'."</br>";
But I get this: Fatal error: Uncaught Error: Call to a member function getAttribute() on null
So it can't locate the element I just created, why?