Jump to content

Xpath Selecting Elements Between Two Other Elements


kebrus

Recommended Posts

Posted

hi guys, sorry if i'm asking in the wrong placei'm looking for a XPATH expression that selects elements/nodes between two elementsimagine this structure:

<stuff></stuff><stuff></stuff><stuff></stuff><stuff></stuff><stuff></stuff><separator1 /><stuff></stuff><separator2 /><stuff></stuff><stuff></stuff><stuff></stuff><stuff></stuff><separator3 /><stuff></stuff><stuff></stuff>

now imagine that i want to only select the four "stuff" elements between "separator2" and "separator3", i'm sick of trying different expression with no success, do you guys know a way of doing it?is it even possible with xpath?

Posted

lol, strangely enough i only had to browse through this same forum a couple of minutes to find out the solution in a completely different threadwell since it might be useful for someone, here is one of the possible solutions

/stuff[not(following-sibling::separator2) and not(preceding-sibling::separator3)]

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...