匹配字符串并提取外部元素?

时间:2014-05-18 08:39:31

标签: dom xpath domxpath

样品:

<div class="luikang">
    <p>Lui Kang information:<br><br>

        <strong>First game:</strong> Mortal Kombat (1992)<br>
        <strong>Created by:</strong> John Tobias<br>
        <strong>Orgin:</strong> Earthrealm<br>
        <strong>Weapon:</strong> Nunchaku<br>
        <strong>Colour:</strong> Red</p>
</div>

我想提取Nunchaku

到目前为止我的尝试:

/html/body//div[@class='luikang']/p/strong[contains(., 'Weapon:')]

我猜我也需要使用它:

[count(preceding-sibling::br) < 1]

有什么建议吗?

1 个答案:

答案 0 :(得分:3)

尝试/html/body//div[@class='short_description']/p/strong[contains(., 'Weapon:')]/following-sibling::text()[1]