【发布时间】:2020-05-16 04:57:59
【问题描述】:
我正在尝试使用 groovy 获取属性 IntegratorCode 和 ProductType 的值。
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:SOAPNYK1="http://www.w3.org/2001/XMLSchema"
xmlns:SOAPNYK2="http://www.w3.org/2001/XMLSchema-instance"
xmlns:SOAPNYK3="http://schemas.xmlsoap.org/soap/encoding/">
<soap:Header>
<Authentication
xmlns="urn:iQQ:API:22:iQQMessages.xsd" EmployeeCode="*****" IntegratorCode="GENERIC" Pwd="******" Usr="SYSUSER"/>
</soap:Header>
<soap:Body>
<CanOfferProduct
xmlns="urn:iQQ:API:22:iQQMessages.xsd">
<OnQuotePackage
xmlns="" ProductType="GAP" QuoteNumber="74859">test
</OnQuotePackage>/>
</CanOfferProduct>
</soap:Body>
</soap:Envelope>
我使用 XmlSlurpur 尝试了以下方法
def result = new XmlSlurper().parseText(xml)
println(result.Envelope.Header[1].Authentication.@IntegratorCode)
//output = IntegratorCode
我想打印 IntegratorCode 的值为“GENERIC”。 我不确定在这种情况下我做错了什么。请帮忙。
【问题讨论】:
标签: groovy xml-parsing xmlslurper