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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.