XPath retrieve nodeContent
I want to retrieve the name from 'Course Leader' from this webpage http://www.westminster.ac.uk/schools/computing/undergraduate/computer-networks/bsc-honours-computer-network-security . How can this be done? I tried
//div[starts-with(@id,'content_div')]/*[self开发者_JAVA技巧::h3 or self::h4 and .='Course Leader' or 'Course Leaders']/following-sibling::p[1]
but it returns the wrong data .. i need to select the 'nodeContent' after Course Leader.
Try this XPath:
//div[starts-with(@id, 'content_div')]
/p[
(preceding-sibling::*[1][self::h3] or preceding-sibling::*[1][self::h4])
and (preceding-sibling::*[1] = 'Course Leader'
or preceding-sibling::*[1] = 'Course Leaders')
]
精彩评论