如何获得 GPathResult 的下一个兄弟?例如我有以下代码:
def priorityIssue = xmlReport.'**'.find { Issue ->
Issue.Priority.text() == priority
}
如何获得 priorityIssue 的下一个兄弟姐妹?
谢谢!
如何获得 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'