<div class="school_row_cell_content">
<div class="center_div">
<img src="/assets/isbiimages/c1504.jpg" alt="School Crest" width="190"></div>
Shelburne Road,
<br class="">Cheltenham,
<br class="">Gloucestershire,
<br class="">United Kingdom,
<br class="">GL51 6HE
<br class="">
<br class=""><strong>Tel:</strong> +44 1242 258000
<br class=""><strong>Fax:</strong> +44 1242 258004
<br class=""><br class=""><strong><a href="http://www.deanclose.org.uk" rel="nofollow" target="_blank" id="154" title="opens in new window" class="school_website_btn">Visit School Website</a></strong>
<br class="">
<br class=""><strong>Founded:</strong>1886<br class=""><br class=""><strong>Headmaster:</strong>
<br class=""><a href="/assets/isbiimages/ph1504.jpg" class="iframe_popups">Mr Bradley Salisbury</a>
<br class=""><br class=""><strong>Registrar:</strong>
<br class="">Mrs Kelly Serjeant
<br class="">
<br class="">This school offers flexi-boarding.
<br class="">
<br class=""><strong>Accreditations and affiliations:</strong>
<br class="">ISBA, HMC, BSA, AGBIS
<br class=""><strong>Religious affiliation:</strong>
<br class="">Church of England<br class=""><strong>Teaching languages:</strong>
<br class="">English
<br class="">
</div>
我想分别抓住这些信息的每一行,但由于只有br标签,我正在努力做到这一点。特别是考虑到课程是空的。我正在尝试这种类型的事情:
//div[@class='school_row_cell_content']/@br
//div[@class='school_row_cell_content']/br[@class=''][1]
但似乎没有到达任何地方。
答案 0 :(得分:0)
诀窍是首先隔离event.data.previous.val()
节点,然后获取前一个或后一个文本节点。因此,要获得包含&#34; Shelburne Road&#34;的文本节点:
br
获取包含&#34; Cheltenham&#34;的文本节点:
//div[@class='school_row_cell_content']/br[1]/preceding-sibling::text()[1]
获取包含&#34;格洛斯特郡&#34;的文本节点:
//div[@class='school_row_cell_content']/br[1]/following-sibling::text()[1]