我只想使用xpath从下面的html中获取“美国国家航空航天局”的值
<table style="margin: 0 5px 0 2px; font-size: 8pt;" class="joaResultsDetailsTable">
<tr>
<td><strong>Department:</strong></td>
<td>National Aeronautics and Space Administration</td>
</tr>
<tr>
<td style="width: 112px;"><strong>Agency:</strong></td>
<td>George C. Marshall Space Flight Center</td>
</tr>
<tr>
<td><strong>Open Period:</strong></td>
<td>9/10/2012 to 9/14/2012</td>
</tr>
<tr>
<td><strong>Who May Apply:</strong></td>
<td>
Current students from education institutions interested in paid opportunities wi...
</td>
</tr>
<tr>
<td style="vertical-align:top;"><strong>Location(s):</strong></td>
<td>Huntsville, Alabama</td>
</tr>
</table>我希望你能帮我
发布于 2012-09-15 03:07:00
你没有提供太多的上下文。以下任何XPath表达式都将满足您声明的要求,即当根据您显示的输入进行计算时,表达式的值应该是字符串‘美国国家航空航天局’:
string(self::table/tr[td='Department:']/td[2])
string(self::table/tr[1]/td[2])
string(self::table/descendant::td[2]))
'National Aeronautics and Space Administration'这些方法中哪一个最适合您取决于您未声明的需求。
https://stackoverflow.com/questions/12430362
复制相似问题