Simple HTML Dom: How to remove elements?

kasakka picture kasakka · Nov 22, 2011 · Viewed 47.8k times · Source

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.

Basically I would do

  1. Get content as HTML string
  2. Remove all image tags from content
  3. Limit content to x words
  4. Output.

Any help?

Answer

Gordon picture Gordon · Nov 22, 2011

There is no dedicated methods for removing elements. You just find all the img elements and then do

$e->outertext = '';