MOTOROLA_Suppor_1
15 years agoContributor
Groovy XmlHolder loops XML response
Hi, I wonder if someone could help me on XmlHlder class to loop over the XML response list.
I know how to do it via XQuery.. but would like do it via script so the generic script could be use by many test case validation.
Please note the order of XML element list is not fixed. XPath validation is not the choice.
Groovy script:
def groovyUtils = new com.eviware.soapui.support.GroovyUtils(context)
def holder = groovyUtils.getXmlHolder("PingVGCardInternalIP#Response")
def resp = holder.getNodeValue("//ns2:ontPingResponse/return/strAttribute)
// Now what ? How do I perform a loop on strAttrbute list
thanks
sheena
====Example soap response for my question is ============
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Header>
<ns2:nbsHeader xmlns:ns2="http://asp.motorola.com/nbs/config/v1-0" xmlns:ns3="http://asp.motorola.com/ws/v1-0">
<authToken>
<userId>asp001</userId>
<sessionId>1892255970</sessionId>
</authToken>
<activityName>ontPing</activityName>
<clientIp>10.13.218.241</clientIp>
</ns2:nbsHeader>
</S:Header>
<S:Body>
<ns2:ontPingResponse xmlns:ns2="http://asp.motorola.com/nbs/config/v1-0" xmlns:ns3="http://asp.motorola.com/ws/v1-0">
<return>
<address>
<tid>Sheena</tid>
<aid>au-5-1-1</aid>
<category>component</category>
<type>ont-ping</type>
</address>
<strAttribute>
<name>ONTPINGRESULTSTATUS</name>
<value>success</value>
</strAttribute>
<strAttribute>
<name>ONTPINGRESULTDATETIME</name>
<value>11/17/2010 16:17:26</value>
</strAttribute>
<strAttribute>
<name>ONTPINGRESULTIPADDRESS</name>
<value>192.169.0.1</value>
</strAttribute>
<strAttribute>
<name>ONTPINGRESULTIPADDRESSTYPE</name>
<value>ipv4</value>
</strAttribute>
<strAttribute>
<name>ONTPINGRESULTAVGRTT</name>
<value>1</value>
I know how to do it via XQuery.. but would like do it via script so the generic script could be use by many test case validation.
Please note the order of XML element list is not fixed. XPath validation is not the choice.
Groovy script:
def groovyUtils = new com.eviware.soapui.support.GroovyUtils(context)
def holder = groovyUtils.getXmlHolder("PingVGCardInternalIP#Response")
def resp = holder.getNodeValue("//ns2:ontPingResponse/return/strAttribute)
// Now what ? How do I perform a loop on strAttrbute list

thanks
sheena
====Example soap response for my question is ============
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Header>
<ns2:nbsHeader xmlns:ns2="http://asp.motorola.com/nbs/config/v1-0" xmlns:ns3="http://asp.motorola.com/ws/v1-0">
<authToken>
<userId>asp001</userId>
<sessionId>1892255970</sessionId>
</authToken>
<activityName>ontPing</activityName>
<clientIp>10.13.218.241</clientIp>
</ns2:nbsHeader>
</S:Header>
<S:Body>
<ns2:ontPingResponse xmlns:ns2="http://asp.motorola.com/nbs/config/v1-0" xmlns:ns3="http://asp.motorola.com/ws/v1-0">
<return>
<address>
<tid>Sheena</tid>
<aid>au-5-1-1</aid>
<category>component</category>
<type>ont-ping</type>
</address>
<strAttribute>
<name>ONTPINGRESULTSTATUS</name>
<value>success</value>
</strAttribute>
<strAttribute>
<name>ONTPINGRESULTDATETIME</name>
<value>11/17/2010 16:17:26</value>
</strAttribute>
<strAttribute>
<name>ONTPINGRESULTIPADDRESS</name>
<value>192.169.0.1</value>
</strAttribute>
<strAttribute>
<name>ONTPINGRESULTIPADDRESSTYPE</name>
<value>ipv4</value>
</strAttribute>
<strAttribute>
<name>ONTPINGRESULTAVGRTT</name>
<value>1</value>