【问题标题】:How to completely clean the element?如何彻底清洗滤芯?
【发布时间】:2011-10-28 13:30:33
【问题描述】:

我用simplehtmldom.sourceforge.net

我需要明确的元素 $e <font size="2"><b>Listen to INT_routine on the January 15th, 2007 Urban-D Radio Podcast!</b></font>

我使用函数:$e->clear() 元素删除,但留下</font>

如何彻底清理元素?

【问题讨论】:

    标签: php html-parsing simple-html-dom


    【解决方案1】:

    我从来没有使用过这个库,但正在浏览它。看看这能不能解决问题..

    echo str_get_html('<font size="2"><b>Listen to INT_routine on the January 15th, 2007 Urban-D Radio Podcast!</b></font>')->plaintext;
    

    或者这个。 .

    $tagtext = (string)"<font size="2"><b>Listen to INT_routine on the January 15th, 2007 Urban-D Radio Podcast!</b></font>";
    var_dump(str_get_html($tagtext)->plaintext);
    

    编辑:

    // Example 
    
    $html = str_get_html("<div>foo <b>bar</b></div>");  
    $e = $html->find("div", 0); 
    
    echo $e->tag; // Returns: " div" 
    
    echo $e->outertext; // Returns: " <div>foo <b>bar</b></div>" 
    
    echo $e->innertext; // Returns: " foo <b>bar</b>"
    
    echo $e->plaintext; // Returns: " foo bar"
    

    【讨论】:

    • 结束?这让我明白了。但对我来说,它应该被删除、标记和一切。
    • 卷心菜。 . ya nea panimya shtu ti guriesh。
    • 纯文本 - prosto vernet mne tekst,一个 mne nuzhno udalitʹ vesʹ 标签
    • 嗯,你知道吗? echo str_get_html('&lt;font size="2"&gt;&lt;b&gt;Listen to INT_routine on the January 15th, 2007 Urban-D Radio Podcast!&lt;/b&gt;&lt;/font&gt;')-&gt;plaintextvar_dump(str_get_html('&lt;font size="2"&gt;&lt;b&gt;Listen to INT_routine on the January 15th, 2007 Urban-D Radio Podcast!&lt;/b&gt;&lt;/font&gt;')-&gt;plaintext)
    猜你喜欢
    • 2020-07-05
    • 1970-01-01
    • 2013-04-25
    • 2014-10-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-10-05
    • 1970-01-01
    相关资源
    最近更新 更多