Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#29 Remove tag

Next_Release
open
nobody
Functions (11)
5
2014-04-17
2012-03-13
Nick Le Mouton
No

Currently you can remove attributes by setting them to null, but when you set a tag to null it enters <>. Although this is easy to then remove with something like preg_replace("##", "", $content) it would be great if simple html dom parser could handle this.

Discussion

  • nickl-
    nickl-
    2012-09-11

    You can try:

    $element->outertext = '';

    To illustrate:

    php> $html = new simple_html_dom();
    php> $html->load_file('t.html');
    php> echo $html->outertext;
    <html> <head> </head> <body> </body> </html>
    php> echo $html->find('img', 0)->outertext;

    php> $html->find('img', 0)->outertext = '';
    php> echo $html->outertext;
    <html> <head> </head> <body> </body> </html>
    php> echo $html->save();
    <html> <head> </head> <body> </body> </html>

    Hope that helps.
    nJoy =)