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: