XPath recursive “parent”-selection in a flat structure
问题 The following XML is given: <root> <element> <id>1</id> </element> <element> <id>2</id> <parentId>1</parentId> </element> <element> <id>3</id> <parentId>2</parentId> </element> <element> <id>4</id> <parentId>3</parentId> </element> <element> <id>5</id> <parentId>2</parentId> </element> <element> <id>6</id> <parentId>5</parentId> </element> </root> Now, I want to select all "parent"-nodes for e.g. element 3. Let's say, the desired output for element 3 should be: element 1 element 2 The desired