tags:

views:

55

answers:

1

how can extract the tag from this html

      <dt>test:</dt>
    <dd id="rating" class="">
  +0 / -0 (0)  </dd>

  <dt>up:</dt>
  <dd>  GMT</dd>

  <dt>By:</dt>

  <dd>
   </dd>
  <dt>example:</dt>
  <dd>5</dd>

  <dt>file:</dt>
  <dd>8</dd>

how can i extract the 5 and 8 in this html code using jsoup....please help me

+1  A: 
doc.select("dt:contains(example) + dd")

Would select the dd containing "5". The complete syntax is available here.

doc.select("dt:contains(example) + dd").first().text()

Would be the 5 itself.

ZoFreX
<h1 class="sprite_torrent torrent_icon">Pretty Little </h1> Element title = doc.select("hl.sprite_torrent torrent_icon").first();it shows error y????
suja
"sprite_torrent" and "torrent_icon" are two separate classes. Doc.select("h1.sprite_torrent") will work, but you can't put both in there like that, just use one or the other.Judging by the documentation, the following MAY work: Doc.select("h1.sprite_torrent.torrent_icon") but I don't know for sure.Also, in the code you pasted you have an "l" (lowercase L) as in "hl" instead of "h1".
ZoFreX
@ZoFreX <div style="height:240px;"><br>Music: Pritam Chakraborty this didnt work for me....
suja
@suja, you've missed a semicolon. Try: `select("div[style=height:240px;]")`, or use a prefix match like `div[style^=height:240]`.
Jonathan Hedley