I am retreiving some html strings from my database and I would like to parse these strings into my DOMDocument. The problem is, that the DOMDocument gives warnings at specia
There is no in XML. The only character entities that have an actual name defined (instead of using a numeric reference) are &, <, >, " and '.
That means you have to use the numeric equivalent of a non-breaking space, which is or (in hex) .
If you are trying to save HTML into an XML container, then save it as text. HTML and XML may look similar but they are very distinct. appendXML() expects well-formed XML as an argument. Use the nodeValue property instead, it will XML-encode your HTML string without any warnings.
// document fragment is completely unnecessary
$otherElement->nodeValue = $row['message'];