我想用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>
我希望你能提供帮助
答案 0 :(得分:2)
您没有提供太多背景信息。以下任何XPath表达式都将满足您声明的要求,即当根据您显示的输入进行评估时,表达式的值应为字符串“National Aeronautics and Space Administration”:
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'
哪种方法最适合您,取决于您未说明的要求。