Php Tidy:删除正文中的链接和样式标签
我必须清理一些 HTML 代码以删除 标记内的
和
标记。
我已经在使用 PHP Tidy 进行一些清理,但我没有找到如何使用 PHP Tidy 删除这些标签。
你有解决办法吗?或者也许是另一个标记清理 PHP 类......
I must cleanup some HTML code to remove <style>
and <link>
tags inside the <body>
tag.
I'm already using PHP Tidy to do some cleanup but I did not found how to remove those tags with PHP Tidy.
Do you have a solution ? Or maybe another markup cleaner PHP class...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不知道如何使用 Tidy 做到这一点,但您可以使用 DOM
对于
元素,将 Xpath 调整为
//body/link
。Don't know how to do that with Tidy, but you can use DOM
For the
<link>
elements, adjust the Xpath to//body/link
.Tidy 的替代方案是 http://htmlpurifier.org/
将此作为一个附加答案,因为它与 DOM 解决方案完全无关。
An alternative to Tidy would be http://htmlpurifier.org/
Made this an additional answer, since it is so completely unrelated to the DOM solution.