Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > select tr>3 with nokogiri

Reply
Thread Tools

select tr>3 with nokogiri

 
 
Pen Ttt
Guest
Posts: n/a
 
      08-29-2010
i found they are equal between not and != in nokogiri xpath
expression.
there is still one problem remain,if my html is the following:

<table>
<tr bgcolor="F3F3F3">
<td align="right" width="240" class="tickerSm">reportdate</td>
<td align="right" width="65" class="tickerSm">10/31/09</td>
<td align="right" width="65" class="tickerSm">10/31/08</td>
<td align="right" width="65" class="tickerSm">10/31/07</td>
<td align="right" width="65" class="tickerSm">10/31/06</td>
<td align="right" width="65" class="tickerSm">10/31/05</td>
</tr>
<tr bgcolor="ffffff">
<td class="tickerSm">Cash &amp; Equivalents</td>
<td align="right" class="ticker">2,493</td>
<td align="right" class="ticker">1,429</td>
<td align="right" class="ticker">1,826</td>
<td align="right" class="ticker">2,262</td>
<td align="right" class="ticker">2,251</td>
</tr>
<tr bgcolor="ffffff">
<td class="ticker">Receivables</td>
<td align="right" class="ticker">595</td>
<td align="right" class="ticker">770</td>
<td align="right" class="ticker">735</td>
<td align="right" class="ticker">692</td>
<td align="right" class="ticker">753</td>
</tr>
</table>

xpath('//table/tr[td[@class="tickerSm"]') get :

<tr bgcolor="F3F3F3">
<td align="right" width="240" class="tickerSm">reportdate</td>
<td align="right" width="65" class="tickerSm">10/31/09</td>
<td align="right" width="65" class="tickerSm">10/31/08</td>
<td align="right" width="65" class="tickerSm">10/31/07</td>
<td align="right" width="65" class="tickerSm">10/31/06</td>
<td align="right" width="65" class="tickerSm">10/31/05</td>
</tr>
<tr bgcolor="ffffff">


xpath('//table/tr[td[@class="ticker"]') get :

<tr bgcolor="ffffff">
<td class="ticker">Receivables</td>
<td align="right" class="ticker">595</td>
<td align="right" class="ticker">770</td>
<td align="right" class="ticker">735</td>
<td align="right" class="ticker">692</td>
<td align="right" class="ticker">753</td>
</tr>

but how can i get the following with xpath expression?
<tr bgcolor="ffffff">
<td class="tickerSm">Cash &amp; Equivalents</td>
<td align="right" class="ticker">2,493</td>
<td align="right" class="ticker">1,429</td>
<td align="right" class="ticker">1,826</td>
<td align="right" class="ticker">2,262</td>
<td align="right" class="ticker">2,251</td>
</tr>
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
 
 
 
Pen Ttt
Guest
Posts: n/a
 
      08-29-2010
a friend tell me,
//table/tr[td[1][@class="tickerSm"] and td[2][@class="ticker"]]
it is ok
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
 
 
 
Ammar Ali
Guest
Posts: n/a
 
      08-29-2010
On Sun, Aug 29, 2010 at 9:40 AM, Pen Ttt <(E-Mail Removed)> wrote:
> a friend tell me,
> //table/tr[td[1][@class="tickerSm"] and td[2][@class="ticker"]]
> it is ok


That's good. Another possible approach is using following-sibling, if
you don't want the first td[@class="tickerSm"]

//table/tr/td[1][@class="tickerSm"]/following-sibling::td[@class!="tickerSm"]

Ammar

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[ANN] nokogiri 1.0.6 Released Aaron Patterson Ruby 2 11-18-2008 03:19 PM
[ANN] nokogiri 1.0.5 Released Aaron Patterson Ruby 4 11-13-2008 09:26 PM
[ANN] nokogiri 1.0.3 Released Aaron Patterson Ruby 0 11-04-2008 10:12 PM
[ANN] nokogiri 1.0.0 Released Aaron Patterson Ruby 0 10-31-2008 01:31 AM
select of select box will select multiple in another box palmiere Javascript 1 02-09-2004 01:11 PM



Advertisments