Posted on 2013-05-17 16:05
沙漠中的魚(yú) 閱讀(5004)
評(píng)論(0) 編輯 收藏 所屬分類(lèi):
其他 、
Java
<section class="imgArea">
<a title="雨傘指數(shù)" target="_blank" href="#"></a>
<span style="#">
不帶傘
</span>
</section>
在上面代碼中,我們首先需要查找屬性title=”
雨傘指數(shù)"的節(jié)點(diǎn),Xpath寫(xiě)法為"http://a[@title='
雨傘指數(shù)']",然后需要找到父節(jié)點(diǎn),父節(jié)點(diǎn)標(biāo)識(shí)為parent,Xpath的寫(xiě)法為“//a[@title='雨傘指數(shù)']/parent::section”,section表示為節(jié)點(diǎn)為Section節(jié)點(diǎn)。
然后需要查子點(diǎn)Span下的文本內(nèi)容,完整的寫(xiě)法為“//a[@title='雨傘指數(shù)']/parent::section/span/text()”