【发布时间】:2011-08-23 14:04:21
【问题描述】:
在数据库中我有一些类似这样的代码
Some text
<pre>
#include <cstdio>
int x = 1;
</pre>
Some text
当我尝试使用 phpQuery 进行解析时,它会失败,因为 <cstdio> 被解释为标签。
我可以使用htmlspecialchars,但仅在pre 标签内应用它,我仍然需要进行一些解析。我可以使用正则表达式,但它会更加困难(我需要处理pre 标签的可能属性)并且使用解析器的想法是避免这种正则表达式的事情。
做我需要做的最好的方法是什么?
【问题讨论】:
标签: php html parsing pre phpquery