开发者

Extract data between two divs using xpath

开发者 https://www.devze.com 2023-04-06 00:54 出处:网络
<div id=\"content\"> <div class=\"sample1\">sample text1</div> <div class=\"sample2\">
    <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

精彩评论

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