XPATH with a table and containing keyword

Questions about XML that are not covered by the other forums should go here.
Grumish
Posts: 1
Joined: Tue Oct 17, 2017 12:40 pm

XPATH with a table and containing keyword

Post by Grumish »

Hi guys,

I have few tabs in my html and one of these tabs contains a table. Problem is that the position of specific tab changes.
Normally I would use for example:
//div[@id='TabbedPanels1']/div/div[6]/table/tbody/tr[2]/td[3]

as in this case the tab im interested in is 6th from left (div[6]).
But now instead of div[6] i need to put 'contains "name"' but I have no idea how to combine that with my code. I'd appreciate any help!

thanks
Costin
Posts: 829
Joined: Mon Dec 05, 2011 6:04 pm

Re: XPATH with a table and containing keyword

Post by Costin »

Hi Grumish,

If I correctly understood, you want to select a table cell from some "div" node(s) that is/are grandchild(ren) of the "div" element whose id is 'TabbedPanels1'.

You could try something like:

Code: Select all

//div[@id='TabbedPanels1']/div/div[contains(., 'name')]/table/tbody/tr[2]/td[3]
if you need to select from all the "div" grandchildren nodes that contain 'name'
and

Code: Select all

//div[@id='TabbedPanels1']/div/div[contains(., 'name')][1]/table/tbody/tr[2]/td[3]
if you need to select only from the 1st grandchildren node containing "name"

I hope this helps!
Costin
Costin Sandoi
oXygen XML Editor and Author Support
Post Reply