2011-09-02 64 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 

在此先感谢

回答