如何使用基于上一个div中文本的XPATH抓取div的内容?

时间:2018-11-09 08:40:07

标签: xpath

我正在尝试使用基于文本的XPATH从以下代码中获取链接文本:“关键功能”

我正在尝试各种版本:

//div[starts-with(., 'Key features')]/following-sibling::td/li

但是似乎运气不太好。

<div class="product-detail">
    <div class="ui grid">
        <div class="sixteen wide tablet six wide computer column top aligned">
            <div class="block__title"><img src="https://test.png" alt="Key features">
                <div class="title">Key features</div>
            </div>
        </div>
        <div class="sixteen wide tablet ten wide computer column top aligned">
            <div class="block__content">
                <table class="ui unstackable fixed table">
                    <tbody>
                        <tr class="one-column">
                            <td>
                                <ul>
                                    <li>10X Rewards (10 points or 4 Miles) for every S$1 spent on Shoes + Bags + Clothes at Online, Retail or Department stores, locally and overseas</li>
                                    <li>Enjoy discounts of up to 50% at Foodpanda, Lazada, Zalora, Reebonz, and more</li>
                                    <li>S$1 spent = 1 Rewards point (All other spend)</li>
                                    <li>First year fee waived for Principal and two (2) Supplementary cards</li>
                                </ul>
                            </td>
                        </tr>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>

1 个答案:

答案 0 :(得分:0)

好吧,我已经为其他阅读本书的人解决了这个问题:

//div[starts-with(., 'Key features')]/following-sibling::div/div/table/tbody/tr/td/ul/li