this is the XML doc
<CT>
<CHILD 1> 10 </CHILD 1>
<CHILD 2> 20 </CHILD 2>
</CT>
<TH>
<CHILD 3> 100 </CHILD 3>
<CHILD 4> 200 </CHILD 4>
</TH>
<CT>
<CHILD 1> 30 </CHILD 1>
<CHILD 6> 40 </CHILD 6>
</CT>
<TH>
<CHILD 7> 300 </CHILD 7>
<CHILD 8> 400 </CHILD 8>
</TH>
I want to fetch the value 30 for which I have used the following xpath root/parent/th../ct/child1
I cannot change root/parent/th which is fixed according to my requirements but I can change the rest of the xpath starting from ../ct/child1
You have error in your xpath expression: not /th../ but /th/../
Also, /root/parent/th selects two th elements and it's not clear which one should be used because both of them have preceding ct with child1 child.
Straightforward answer is
I.e. first preceding sibling element CT of last TH.
But for more useful answer we need more info.