Get all ul elements in between two h3 tags

205 Views Asked by At

Following is how the element looks like on the page:

enter image description here

Programs and Courses are h3 tags. I want all the ul tags in between Programs and Courses. Following XPath gives me all the ul comes after Programs:

"//h3[.='Programs']/following::ul"

How do I filter it to have the only ul which comes in between Courses and Program.

Screenshot Source: https://catalog.fullerton.edu/preview_entity.php?catoid=16&ent_oid=1837&returnto=1920

1

There are 1 best solutions below

2
On BEST ANSWER

Try below XPath to get required ul nodes:

//h3[.='Programs']/following-sibling::ul[following-sibling::h3[.='Courses']]