dom - How to stop querying when it reaches a specific class with XPath? -
say have following:
<div class="data"> <h2 class="entry-contenth2">preparation</h2> <h2>airplanes</h2> <ul> <li><strong>3 large</strong> wings</li> <li><strong>2</strong>doors</li> </ul> <h2>car</h2> <ul> <li><strong>4</strong> doors</li> <li><strong>1 cup</strong> holder</li> </ul> <h2 class="stopheader">execution</h2> <h2>motorcycles</h2> <ul> <li>easy learn</li> </ul> </div> i'm trying query of <p></p> tags text after <h2>preparing</h2>, want stop @ last <p></p> before stopheader class.
this code came with:
//h2[contains(.,"preparation")]/following-sibling::h2/text()[not(preceding::h2[@class="stopheader"])] #and //h2[contains(.,"preparation")]/following-sibling::h2/text()[not(preceding::h2[contains(., "execution")])]
try below xpath desired output:
//h2[.="preparation"]/following-sibling::h2[./following-sibling::h2[.="execution"]]/text() this should return text content of each header (h2) between "preparation" , "execution"
Comments
Post a Comment