2011-09-02 15 views
0

jsoup 1.6.1을 사용하고 html에서 iframe 태그를 제거하려고 할 때 문제가 발생합니다. iframe에 본문이 없으면 (즉, < iframe pro = value />), remove() 메소드는 thet 태그 다음의 모든 내용을 제거합니다. 여기 내 샘플 코드입니다.jsoup : iframe 태그 제거

This is start. 

그러나 나는 결과를 기대하고있다 - -

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()); 

그것은 나에게 돌려 사전

답변

1

에서

This is start. This is end 

감사 필요 iframe 대응 닫는 태그를 나타납니다.

http://msdn.microsoft.com/en-us/library/ie/ms535258(v=vs.85).aspx http://stackoverflow.com/questions/923328/line-after-iframe-is-not-visible http://www.w3resource.com/html/iframe/HTML-iframe-tag-and-element.php

그래서, Jsoup는 다음입니다 : 당신은 자기 닫는 태그를 사용할 수 없습니다 spec 및 iframe 태그를 따르고 그 태그를 본문으로 사용합니다. iframe을 제거하면 "This is the end"도 제거됩니다.