child::para[attribute::type=warning][position()=2] selects the second para child of the context node that has a type attribute with value warning <?xgrep-match [xgrep-test1.xml]--------------------------------?> <para name="lastPara" type="warning"/>