java - How to get an element by class name -


<td class="calendar_day" data-day-index="6">   <div class="calendar_date">mar. 1st</div>   <div class="calendar_cell_content">     <ul>       <li class=""> 

i trying value class="calendar_date" (mar. 1st).

i have html code i'm trying parse saved in string variable named returned.

document doc = jsoup.parse(returned); elements elem = doc.getelementsbyclass("calendar_date"); string date = elem.first().text(); 

if i'm doing date string null.

firstly, should check whether content of variable returned same describe above.

then, should try latest version of jsoup 1.7.3. have run following code, works.

    string returned             = "<td class=\"calendar_day\" data-day-index=\"6\">\n"             + "  <div class=\"calendar_date\">mar. 1st</div>\n"             + "  <div class=\"calendar_cell_content\">\n"             + "    <ul>\n"             + "      <li class=\"\">";     document doc = jsoup.parse(returned);     elements elem = doc.getelementsbyclass("calendar_date");     string date = elem.first().text();     system.out.println(date); 

the result expected: mar. 1st


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -