I am trying to get the root node of a PHP DOM Document. This is usually done by doing something like this:
$doc->documentElement;
However, trying this on a HTML string that contains a doctype:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml">...
and that is loaded into a DOM Document object like so:
$doc = new DOMDocument();
$doc->loadHTML($html);
returns the root node as the html
tag and not the doctype tag! I am guessing this because of the weird characters <!
- is there anyway to return the root node correctly?