简单的HTML Dom:如何去除元素? [英] Simple HTML Dom: How to remove elements?
本文介绍了简单的HTML Dom:如何去除元素?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想使用简单的HTML DOM来删除文章中的所有图像,所以我可以轻松地创建一个新的代码段的一小段文本,但我还没有想到如何删除元素。
I would like to use Simple HTML DOM to remove all images in an article so I can easily create a small snippet of text for a news ticker but I haven't figured out how to remove elements with it.
基本上我会做
- 以HTML字符串获取内容
- 从内容中删除所有图片标签
- 将内容限制为x字
- 输出。
- Get content as HTML string
- Remove all image tags from content
- Limit content to x words
- Output.
任何帮助?
推荐答案
没有专门的删除方法元素。你只需找到所有的img元素,然后执行
There is no dedicated methods for removing elements. You just find all the img elements and then do
$e->outertext = '';
这篇关于简单的HTML Dom:如何去除元素?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文