0
我的XML返回基於條件的另一個節點是這樣的:在常規
<app>
<module>
<web>
<web-uri>abc.war</web-uri>
<context-root>abc</context-root>
</web>
</module>
<module>
<web>
<web-uri>abc.pl</web-uri>
<context-root>adf</context-root>
</web>
</module>
</app>
我需要的context-root
值只有web-uri
值結束與戰爭。作爲一個列表。
我寫的是這樣的:
def ctxRootList = nodeList.'**'.findAll{
ctxRoot ->
ctxRoot.module.web."web-uri".text().endsWith(".war")
}*.text()
有2個問題在這裏:
- 我不知道如何讓其他的兄弟姐妹,而在
web-uri
值 - 結果現在似乎作爲所有這些值的連接字符串返回。那麼,如何讓它返回作爲值
爲什麼在上下文之後的另一顆星 - 根? – Vik
@Vik,因爲可能有多個'context-root'元素,所以'text()'在每個找到的元素上被調用。 – Opal