Count the number of tags
<ns0:esbEnvelope xmlns:ns0="http://moneygram.com/esb_v3">
<ns0:header>
<ns0:messageGUID>00000164bdc7c9a7-1d58dec</ns0:messageGUID>
<ns0:sessionGUID/>
<ns0:routingContext>
<ns1:serviceFunctionID xmlns:ns1="http://moneygram.com/core/common_v3">GetUCP1705</ns1:serviceFunctionID>
<ns1:esbClientSystemId xmlns:ns1="http://moneygram.com/core/common_v3">GetUCPTransactionHistoryOrchestrator</ns1:esbClientSystemId>
<ns1:mgiAPIID xmlns:ns1="http://moneygram.com/core/common_v3">1705</ns1:mgiAPIID>
<ns1:poeTypeID xmlns:ns1="http://moneygram.com/core/common_v3">AGENTCONNECT</ns1:poeTypeID>
<ns1:agentLocationID xmlns:ns1="http://moneygram.com/core/common_v3"/>
<ns1:configurationExceptionToken xmlns:ns1="http://moneygram.com/core/common_v3"/>
<ns1:esbEnvelopeVersion xmlns:ns1="http://moneygram.com/core/common_v3">v3</ns1:esbEnvelopeVersion>
</ns0:routingContext>
<ns0:processingInstruction>
<ns1:action xmlns:ns1="http://moneygram.com/core/common_v3">MDM_GetUCP_SYNC_HTTP_1705</ns1:action>
<ns1:language xmlns:ns1="http://moneygram.com/core/common_v3">en-US</ns1:language>
<ns1:rollbackTransaction xmlns:ns1="http://moneygram.com/core/common_v3">true</ns1:rollbackTransaction>
<ns1:logLevelCode xmlns:ns1="http://moneygram.com/core/common_v3">2</ns1:logLevelCode>
<ns1:serviceTimeoutMillisecs xmlns:ns1="http://moneygram.com/core/common_v3">15000</ns1:serviceTimeoutMillisecs>
<ns1:customFields xmlns:ns1="http://moneygram.com/core/common_v3">
<ns1:NameValue>
<ns1:Name>targetAudience</ns1:Name>
<ns1:Value>AGENT_FACING</ns1:Value>
</ns1:NameValue>
<ns1:NameValue>
<ns1:Name>langaugeISOCode</ns1:Name>
<ns1:Value>eng</ns1:Value>
</ns1:NameValue>
<ns1:NameValue>
<ns1:Name>langaugeCode</ns1:Name>
<ns1:Value>en</ns1:Value>
</ns1:NameValue>
<ns1:NameValue>
<ns1:Name>MediatorUseTypeCode</ns1:Name>
<ns1:Value>RQST</ns1:Value>
</ns1:NameValue>
<ns1:NameValue>
<ns1:Name>isNewMgiReceiveTransactionSessionIDFlag</ns1:Name>
<ns1:Value>true</ns1:Value>
</ns1:NameValue>
</ns1:customFields>
</ns0:processingInstruction>
<ns0:ExternalClientHeader xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ns1:clientRequestID xmlns:ns1="http://moneygram.com/core/common_v3">00000164bdc7c9a7-1d58dec</ns1:clientRequestID>
<ns1:clientSoftwareVersion xmlns:ns1="http://moneygram.com/core/common_v3">1705</ns1:clientSoftwareVersion>
<ns1:timestamp xmlns:ns1="http://moneygram.com/core/common_v3">2018-09-17T16:08:01.122</ns1:timestamp>
</ns0:ExternalClientHeader>
</ns0:header>
<ns0:responsePayload>
<ns1:orchestrateGetUCPResponse xmlns:ns1="http://moneygram.com/core/service/OrchestrateGetUCP1705">
<consumerProfile>
<cityOfBirth>GBRDDDD</cityOfBirth>
<countryOfBirthCountryCode>GBR</countryOfBirthCountryCode>
<dateOfBirth>1990-09-09</dateOfBirth>
<gender>FEMALE</gender>
<preferredLanguage>en-US</preferredLanguage>
<primaryCitizenshipCountryCode>GBR</primaryCitizenshipCountryCode>
<emailAddress>
<emailAddress>RKUMARDD@MONEYGRAM.COM</emailAddress>
<startDate>2018-10-19T21:10:52-05:00</startDate>
<stronglyAuthenticated>false</stronglyAuthenticated>
<type>EMAIL</type>
<notificationPreference>
<method>E-MAIL</method>
<optIn>false</optIn>
<preferredLanguage>en-US</preferredLanguage>
<startDate>2018-10-19T21:10:52-05:00</startDate>
<stronglyAuthenticated>false</stronglyAuthenticated>
<type>TXNN</type>
</notificationPreference>
<notificationPreference>
<method>E-MAIL</method>
<optIn>false</optIn>
<preferredLanguage>en-US</preferredLanguage>
<startDate>2018-10-19T21:10:52-05:00</startDate>
<stronglyAuthenticated>false</stronglyAuthenticated>
<type>MKTN</type>
</notificationPreference>
</emailAddress>
For the above response i need to get the count of email address .I wrote the below and i am getting 2 instead of 1.Please assist.
import com.eviware.soapui.support.XmlHolder;
def groovyUtils = new com.eviware.soapui.support.GroovyUtils(context);
def response = groovyUtils.getXmlHolder("Operation#Response");
response.namespaces["ns1"] = "http://moneygram.com/core/service/OrchestrateGetUCP1705";
testRunner.testCase.getTestStepByName('Operation').run(testRunner,context)
def ReqFile ="C:/Program Files/Java/any.xml"
def g = context.expand('${Operation#Response#//*//consumerProfile//phoneNumber}');
def i1 = response["count(//consumerProfile//phoneNumber)"];
log.info i1
def i = new File(ReqFile )
i.write(g, "UTF-8")