java - How to parse 'div' without name? -
using jsoup:
element movie_div = doc.select("div.movie").first();
i got such html-code:
<div class="movie"> <div> <div> <strong>year:</strong> 2014 </div> <div> <strong>country:</strong> usa </div> </div> </div>
how can use jsoup extract country , year?
for example html want extracted values "2014"
, "usa"
.
thanks.
use
element e = doc.select("div.movie").first().child(0); list<textnode> textnodes = e.child(0).textnodes(); string year = textnodes.get(textnodes.size()-1).text().trim(); textnodes = e.child(1).textnodes(); string country = textnodes.get(textnodes.size()-1).text().trim();
Comments
Post a Comment