To filter the n-th matching node in your XPath expression using xmlstarlet, you can use the predicate [n] to select a specific node by its position. For example, to get the n-th node where @text="Rooted debugging", you can modify your command like this:
bashcat dump.xml | xmlstarlet select --template --value-of '(//node[@text="Rooted debugging"])[n]/@resource-id'
(//node[@text="Rooted debugging"])[n] selects the n-th node in the entire document that matches the condition @text="Rooted debugging".n with the desired position (e.g., [1] for the first match, [2] for the second, etc.).If you want the 3rd matching node:
bashcat dump.xml | xmlstarlet select --template --value-of '(//node[@text="Rooted debugging"])[3]/@resource-id'
Vibe can make mistakes. Check answers. Learn more