开发者

Extract data between two divs using xpath

    <div id="content">
        <div class="sample1">sample text1</div>
        <div class="sample2">
           <span style="float:right">some text2</span>
           <b>some text2</b>
        </div>
        <div class="sample3"> sample text <a href="#">This page</a> 3</div>
   开发者_如何学C     <p>paragraph 1</p>
        <p>paragraph 2</p> 
        <div class="sample4">sample text4</div>
   </div>

I want to extract data that is between these classes "sample2" and "sample4".

The out put will show lik this

sample text 3

paragraph 1

paragraph 2

How come?


//*[
    preceding-sibling::div[@class = 'sample2'] 
        and following-sibling::div[@class = 'sample4']
]/text()
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜