DOMDocumentFragment::appendXML(): Entity: line 45: parser error : PCDATA invalid Char value 8

删除多余的控制字符即可~

$val = preg_replace('/[[:cntrl:]]/mu', '', $val);