When you do this:
$d = new DOMDocument();
$e = new DOMElement('myelement', 'hi bye');
$d->appendChild($e);
$d->loadXML($d->saveXML());
..you get the following error:
PHP Warning: DOMDocument::loadXML(): Entity 'nbsp' not defined in Entity, line: 2 in php shell code on line 1
Why does this happen? Shoudn’t libxml handle entities correctly?
Use
loadHTML()instead since this entity is a HTML entity and not a generic XML entity.http://www.php.net/manual/en/domdocument.loadxml.php#89212