How to find nearest match from current context node
See the question and my original answer on StackOverflowI think an XPATH like this (from the current CONTROLLER2 node) should do it:
string xPath = "../preceding-sibling::tr[starts-with(td , 'ABC-')][1]/td[starts-with(. , 'ABC-')]";
It means
- get back once ancestor level up (..)
- from there, select all preceding sibling TR elements that have TD elements that start with 'ABC-'
- get the first (reverse order) of these TR.
- from this TR element, get TD elements that starts with 'ABC-'