943,175 Members | Top Members by Rank

Ad:
Aug 29th, 2010
0

how to write this kind of xpath exprssion?

Expand Post »
there is table :
<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 & 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"]') can 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"]') can 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>

how to write a xpath expression to get the following?
<tr bgcolor="ffffff">
<td class="tickerSm">Cash & 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>
Similar Threads
Reputation Points: 7
Solved Threads: 0
Newbie Poster
luofeiyu is offline Offline
7 posts
since Aug 2010
Aug 29th, 2010
0
Re: how to write this kind of xpath exprssion?
Quote ...
xpath('//table/tr[td[@class="tickerSm"]') can get:
...reportdate
that should be getting your BOTH 'reportdate' and 'Cash & Equivalents' since it too has class="tickerSm"

From what you posted:
xpath('//table/tr[1]) should give you 'reportdate' row
xpath('//table/tr[2]) should give you 'Cash & Equivalents' row
xpath('//table/tr[3]) should give you 'Receivables' row
Reputation Points: 116
Solved Threads: 243
Veteran Poster
hielo is offline Offline
1,123 posts
since Dec 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in JavaScript / DHTML / AJAX Forum Timeline: Multiple image rollover
Next Thread in JavaScript / DHTML / AJAX Forum Timeline: javascript web music player control





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC