如何使用 GPathResult 获取下一个兄弟姐妹

How to get the next sibling with GPathResult

如何获取 GPathResult 的下一个同级?例如我有以下代码:

def priorityIssue = xmlReport.'**'.find { Issue ->
   Issue.Priority.text() == priority
}

如何获得 priorityIssue 的下一个同级?

谢谢!

大致是这样的:

import groovy.util.XmlSlurper

def xml = new XmlSlurper().parseText('''
<issues>
    <issue>
        <id>1</id>
        <priority>1</priority>
    </issue>
    <issue>
        <id>2</id>
        <priority>2</priority>
    </issue>
</issues>
''')
def p = '1' 
def priorityIssue = xml.'**'.find { issue ->
    issue.priority.text() == p
}
def kids = priorityIssue.parent().children().list()
def idx = kids.indexOf(priorityIssue)
def sibling = kids[++idx]
assert sibling.id.text() == '2'