Iframe traverse using jsoup

I have such an html structure. I want to get a second table that has no class or id. How to get second table from iframe ?

 <iframe> <html> <body> <table><table> <table> <tr><td></td></tr> <tr><td></td></tr> </table> </body> </html> </iframe> 

I try so hard

 Elements iframe = doc.select("iframe"); for(Element e : iframe) { System.out.println(e.child(0)); } 

Can anybody help me?

+4
source share
1 answer

Do you want to cross the iframe element? Better get content from iframe source as

 Element iframe = doc.select("iframe").first(); String iframeSrc = iframe.attr("src"); if(iframeSrc != null) { iframeContentDoc = Jsoup.connect(iframeSrc).get(); } 

You can do it only.

+8
source

All Articles