我正在尝试使用QueryPath来操作PHP中的HTML.它工作得很好,直到某些utf-8字符与->html()和->text()方法一起使用。即使使用html字符也不能解决问题。
有问题的例子:
$html = "<html><body id='a'>test</body></html>";
$html = qp($html, "#a" )->text("å")->top()->html(); // results in disappearing html code
//$html = qp($html, "#a" )->html("å")->top()->html(); // generates warnings
echo $html我已经尝试了许多组合,但都没有成功。
如果我注释掉第二行并取消注释第三行,则会收到以下警告: Warning: DOMDocumentFragment::appendXML():Entity:第1行:解析器错误: Entity 'aring‘未在第1208行的D:\Inetpub\wwwroot\QueryPath-2.1.2-minimal\QueryPath.php中定义警告: DOMDocumentFragment::appendXML():§在第1208行的D:\Inetpub\wwwroot\QueryPath-2.1.2-minimal\QueryPath.php中警告: DOMDocumentFragment::appendXML():^在第1208行的D:\Inetpub\wwwroot\QueryPath-2.1.2-minimal\QueryPath.php中
发布于 2012-06-25 16:34:59
我注意到我必须将php文件的编码设置为utf-8,它就起作用了。然而,我仍然没有找到一种使用html字符的方法。
https://stackoverflow.com/questions/11176650
复制相似问题