Selecting the following siblings

Task

Source document

Your are at the green marked position

<products>
  <product id="1" name="Teekanne" price="25.00" category="1" />
  <product id="2" name="Bleistift" price="0.29" category="2" />
  <product id="3" name="Lautsprecher" price="19.00" category="2" />
  <product id="4" name="Tasse" price="1.99" category="1" />
  <product id="5" name="Apfelsaft" price="1.49" category="1" />
  <product id="6" name="CD-Rohling" price="0.89" category="2" />
  <category id="1" name="Sortiment 2005" />
  <category id="2" name="Sortiment 2006" />
</products>

Challenge

Select the following product-siblings relatively from their current node.

Desired selection (XML-output)

  • <product id="4" name="Tasse" price="1.99" category="1" />
  • <product id="5" name="Apfelsaft" price="1.49" category="1" />
  • <product id="6" name="CD-Rohling" price="0.89" category="2" />

Exercise

Your input

Eine Lösung wäre: Lösung