2011-09-02 79 views
0

我正在使用jsoup 1.6.1,並在嘗試從html中刪除iframe標記時遇到問題。當iframe沒有任何內容時(即< iframe pro = value />),remove()方法將刪除t標籤後的所有內容。這是我的示例代碼。jsoup:刪除iframe標記

String html ="&lt;p> This is start.&lt;/p>&lt;iframe frameborder="0" marginheight="0" />&lt;p> This is end&lt;/p>"; 
Document doc = Jsoup.parse(html,"UTF-8");<br> 
doc.select("iframe").remove();<br> 
System.out.println(doc.text()); 

它返回到我 -

This is start. 

但我期待的結果 -

This is start. This is end 

在此先感謝

回答