starts with and ends with in xpath

8.5k Views Asked by At

Following is how the element looks like on the page:

enter image description here

I want all the li which comes right after General Engineering Courses. General [COURSE_NAME] Courses is common text on other pages as well.

So basically I want all the li which come right after GENERAL [COURSE_NAME] Courses.

I wrote the following XPath, but unfortunately, it's causing DOMException while executing the XPath on Chrome.

//*[starts-with(text(), 'GENERAL') and ends-with(text(), 'COURSES')]

enter image description here

Page: http://catalog.fullerton.edu/content.php?catoid=16&navoid=1922

1

There are 1 best solutions below

0
On

You need use XPath Axes, the following-sibling

//p[starts-with(strong,'GENERAL ') and substring(strong, string-length(strong)-7)=' COURSES']/following-sibling::ul/li