Xml xpath在html代码中查找值

Xml xpath在html代码中查找值,xml,xpath,Xml,Xpath,我只想使用xpath从下面的html中获取值“美国国家航空航天局” <table style="margin: 0 5px 0 2px; font-size: 8pt;" class="joaResultsDetailsTable"> <tr> <td><strong>Department:</strong></td&

我只想使用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>

部门:
美国国家航空航天局
代理机构:
乔治·C·马歇尔航天飞行中心
开放期:
2012年9月10日至2012年9月14日
谁可以申请:
目前来自教育机构的学生对付费机会感兴趣。。。
地点:
阿拉巴马州亨茨维尔

如果你能帮忙,我希望你不要提供太多的背景。以下任何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'

以下哪项最适合您取决于您未说明的需求

您正在使用XHTML吗?如果不是,您可能需要为文档编写一个模式,在最坏的情况下,HTML将不会解析为XML。