【发布时间】:2015-09-11 10:34:49
【问题描述】:
我有这样的字符串:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<NS1:createResponse xmlns:NS1="http://abc.ru/esf/dto/srvMessages">
<NS1:Header>
<integrationID>wd457665grtyy5444</integrationID>
<nativeID/>
<resultInfo>
<status>ERROR</status>
<errorInfo>
<descr>Error:ESB-002: Failed to createSub. Code=Error whilst processing message:Fault from GW: faultcode=tns:Client faultstring=Could not map property BonusMalusRateForKSK detail=,,</descr>
</errorInfo>
</resultInfo>
</NS1:Header>
</NS1:createResponse>
</soapenv:Body>
</soapenv:Envelope>
我有这样的代码:
MessageExchange[] me = myTestStepResult.getMessageExchanges()
log.info "[ERROR] " + me[0].getResponseContent()
def matches = me[0].getResponseContent() =~ '<errorInfo>(.+?)</errorInfo>'
log.info "[Result" + matches
我想用 groovy 做的是在 <errorInfo</errorInfo> 标签之间获取消息
但结果我喜欢:java.util.regex.Matcher[pattern=<errorInfo>(.+?)</errorInfo> region=0,790 lastmatch=]
你能帮我用 groovy 获取响应文本吗
【问题讨论】:
-
<errorInfo>\s*<descr>([^<]+)</descr>. -
你可以试试:\
-
还是有这个错误:java.util.regex.Matcher[pattern= \
标签: java regex grails xpath groovy