How can I find the last node that contains a specific structure?
<defect-event>
<event-assigned-to>
<assigned-to-user>
<last-name>Doe</last-name>
<first-name>John</first-name>
<middle-name></middle-name>
</assigned-to-user>
</event-assigned-to>
</defect-event>
There can be many “defect-event” nodes at the same level, below or above the one with the “assigned-to-user” sub node.
There can also be multiple “defect-event” nodes with the “assigned-to-user” sub node.
I need to find the last one “defect-event” node which contains the “assigned-to-user” sub node.
Thanks!
Something on these lines is probably what you want:
In effect, you’re saying “find me all the
defect-eventwhich contains anevent-assigned-tocontaining anassigned-to-user, and then just give me the one whoseposition()islast()“.Having said that, you might need to tweak this depending on the context you’re in when you try to find the node, and what you’re doing to the node (eg: behaviour might vary if you’re in a
for-eachloop as opposed to anapply-templatessituation).