<div class="accrd-row">
<h3 class="ui-helper-reset ui-accordion-header ui-corner-top ui-accordion-header-collapsed ui-corner-all ui-state-default ui-accordion-icons" role="tab" id="ui-id-1" aria-controls="ui-id-2" aria-selected="false" aria-expanded="false" tabindex="0"><span class="ui-accordion-header-icon ui-icon ui-icon-triangle-1-e"></span><span class="icon icon-ki-act-panda"></span><a href="#">Outdoor Activities</a></h3>
<div class="accrd-detail ui-accordion-content ui-corner-bottom ui-helper-reset ui-widget-content" id="ui-id-2" aria-labelledby="ui-id-1" role="tabpanel" aria-hidden="true" style="display: none;">Need to grab this text here</div>
</div>
我正在尝试获取文本:
Need to grab this text here
基于此,上面的跨度中包含单词“ panda”。我知道这就像:
//span/@class[contains(.,'panda')]/following-sibling::a/div
但是我似乎无法理解这一点。
答案 0 :(得分:0)
您需要返回span的父级,因为您要查找的div是h3的同级兄弟而不是span。
可能有一种更好的方法,但这对我来说很有用,可以获取所需的div元素:
//h3//span[contains(@class, 'panda')]/parent::h3/following-sibling::div