Search code examples
xpathxpath-2.0xpathnavigator

Multiple xpath expressions


Can somebody help me to write this expression as it is driving me crazy!

Take this site for example http://www.jigsaw-online.com/

I'm trying to build up an expression where I can get all links under a category of my choice.

E.g. I want all four /a under New In

I can get the New In link via

//header//li[@class='nav-level-1-list']/a[contains(text(),'New In')]

I've then tried going up a level to then get all the links via:

//header//li[@class='nav-level-1-list']//li/a

but that doesn't work because it's still trying to find an anchor that contains 'New In'

How can I combine these two expressions together so I can get all the links under the category?


Solution

  • //header//li[@class='nav-level-1-list']/ul[preceding-sibling::a[contains(text(),'New In')]]//li/a (did not test it, has nothing to run xpath on html)