-1

I have a navigation menu in which I wish to bold certain areas of the menu using an injection script. I wish to use a generic xpath to bold each of the items in the menu that I want. Problem is, the menu has some selections of the same name that I do not bolded, all in one particular sub-menu.

The menu would look something like this:

<ul class="main-menu">
  <li class="sub-menu">Employees</li>
  <ul>
    <li>Address List</li>
  </ul>
  <li class="sub-menu">Clients</li>
  <ul>
    <li>Address List</li>
  </ul>
  <li class="sub-menu">Contractors</li>
  <ul>
    <li>Address List</li>
  <ul>
</ul>

To find the 'Address list', I might use an Xpath similar to this...

//ul[@class="main-menu"]//li[text()="Address List"]

Problem is, that would highlight all "Address List" items, and I do not want anything in the Employees list.

Keep in mind, this is only a sample menu, and I need to highlight more stuff all over the menu, both in sub-menus and on the main list, but I do not want to highlight anything in the Employees sub-menu, I want to exclude just those items in that list.

I've tried 'except' and 'not' but I guess I'm not getting how to use it or am putting it in the wrong context.

Steve S
  • 69
  • 7

1 Answers1

0

Try this on your actual html and see if it works:

//ul[@class="main-menu"]//
li[not(./text()="Employees")]
/following-sibling::ul/li[text()="Address List"]
Jack Fleeting
  • 24,385
  • 6
  • 23
  • 45
  • That's not it quite yet, but it has definitely given me a step forward. I'll get back to you when I can play with it a bit. – Steve S Feb 19 '21 at 19:30