我想在BASIC EPS下找到td值,但是有两个这样的列,因此很难选择我想要的第二列(从值> 0.82> 1.05> .74等开始) 。我在一个带有简单html dom库的php脚本中这样做,所以让我知道它是如何实现的。我使用的代码如下。但是上面的代码给了我两次基本的eps值,而我在第二列只需要一次。
<tr height="22px">
<td colspan="2" class="detb" width="40%">EPS Before Extra Ordinary</td>
<td align="right" class="detb"></td>
<td align="right" class="detb"></td>
<td align="right" class="detb"></td>
<td align="right" class="detb"></td>
</tr>
<tr height="22px">
<td colspan="1" class="det" width="40%">Basic EPS</td>
<td align="right" class="det">0.82</td>
<td align="right" class="det">1.05</td>
<td align="right" class="det">0.74</td>
<td align="right" class="det">1.00</td>
<td align="right" class="det">0.96</td>
</tr>
<tr height="22px">
<td colspan="1" class="det" width="40%">Diluted EPS</td>
<td align="right" class="det">0.82</td>
<td align="right" class="det">1.05</td>
<td align="right" class="det">0.74</td>
<td align="right" class="det">1.00</td>
<td align="right" class="det">0.96</td>
</tr>
<tr height="22px">
<td colspan="2" class="detb" width="40%">EPS After Extra Ordinary</td>
<td align="right" class="detb"></td>
<td align="right" class="detb"></td>
<td align="right" class="detb"></td>
<td align="right" class="detb"></td>
</tr>
<tr height="22px">
<td colspan="1" class="det" width="40%">Basic EPS</td>
<td align="right" class="det">0.82</td>
<td align="right" class="det">1.05</td>
<td align="right" class="det">0.74</td>
<td align="right" class="det">1.00</td>
<td align="right" class="det">0.96</td>
</tr>
<tr height="22px">
<td colspan="1" class="det" width="40%">Diluted EPS</td>
<td align="right" class="det">0.82</td>
<td align="right" class="det">1.05</td>
<td align="right" class="det">0.74</td>
<td align="right" class="det">1.00</td>
<td align="right" class="det">0.96</td>
</tr>
$mn=$html->find("td.det");
if($mn->plaintext=='Basic EPS'){
foreach($mn[1] as $r1){
if($r1->plaintext == 'Basic EPS'){
$next_td = $r1->next_sibling();
$qeps10 = $next_td->plaintext;
echo $qeps10."<br>";
$next_td_1=$next_td->next_sibling();
$qeps9 = $next_td_1->plaintext;
echo $qeps9."<br>";
$next_td_2=$next_td_1->next_sibling();
$qeps8 = $next_td_2->plaintext;
echo $qeps8."<br>";
$next_td_3=$next_td_2->next_sibling();
$qeps7 = $next_td_3->plaintext;
echo $qeps7."<br>";
}
}
}