java - Get severals class same name with JSOUP -


is there way html severals class same name plugin jsoup of java ?

for example:

<div class="div_idalgo_content_result_date_match_local"> blablabla </div>  <div class="div_idalgo_content_result_date_match_local"> 123456789 </div> 

i'd blablabla in 1 string , 123456789 in another.

i wish question understandable.

this can done in several different ways.

if want select div's class name above, can use following:

    elements div = doc.select("div.div_idalgo_content_result_date_match_local"); 

this give collection of element can iterate over. if after select perhaps first one, can use :eq(0)-parameter, or first()-parameter.

    element firstdiv = div.first(); 

or

    elements div = doc.select("div.div_idalgo_content_result_date_match_local:eq(0)"); 

note second method selecting document, while in first method select collection of element's. can of course change value of :eq(0) else matches element. there many useful selectors can use have included link in end of answer.

the following code split div's two:

    elements div = doc.select("div.div_idalgo_content_result_date_match_local");     element firstdiv = div.first();     element seconddiv = div.get(1);      system.out.println("this first div: " + firstdiv.text());     system.out.println("this second div: " + seconddiv.text()); 

jsoup cookbook - selector syntax


Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -