开发者

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')
     ]
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜