在執行我收到錯誤即groovy.lang.MissingPropertyException腳本:沒有這樣的屬性:客戶ID類Groovy腳本錯誤沒有這樣的屬性:客戶ID爲
腳本
import org.w3c.dom.Node
import org.w3c.dom.NodeList
NodeList nodes = employeeServiceResponse.getFirstChild().getChildNodes()
String firstName = null
String lastName = null
for (int i = 0 i < nodes.getLength() i++) {
Node node = nodes.item(i)
if ("firstName".equals(node.getLocalName()))
firstName = node.getFirstChild().getNodeValue()
else if ("lastName".equals(node.getLocalName()))
lastName = node.getFirstChild().getNodeValue()
}
if (firstName != null && lastName != null){
println 'Found employee: ' + firstName + ' ' + lastName
discountPercent = 10
return true
} else {
println 'Employee not found: ' + customerId
discountPercent = 0
return false
}
我新的常規腳本可以請任何人幫助我。腳本解析數據。
你可以舉一些例子的XML?你是如何創建'employeeServiceResponse'? –