loetje
10 years agoNew Contributor
Parsing XML from response
Hi,
First of all, i'm a compete noob to soapui. I've looked extensively trough the available explanations here http://www.soapui.org/scripting---prope ... properties and here http://www.robert-nemet.com/2011/11/gro ... oapui.html to solve my problem to no avail.
Can anyone provide me with a step by step instructions to do the following
First of all, i'm a compete noob to soapui. I've looked extensively trough the available explanations here http://www.soapui.org/scripting---prope ... properties and here http://www.robert-nemet.com/2011/11/gro ... oapui.html to solve my problem to no avail.
Can anyone provide me with a step by step instructions to do the following
- i send a soap request
- from the response i get i want to parse some of the node data in a text file or show it in the script log.
- i've made a testcase with the request
- Part of the rsponse i get:
<ns0:body>
<ns0:contractrekeningen>
<ns0:contractrekening>
<ns0:contractrekeningIdentificatie>200000000538</ns0:contractrekeningIdentificatie>
<ns0:BTWcategorie>Energie Debiteur 21%</ns0:BTWcategorie>
<ns0:communicatievoorkeur>Individueel Brief</ns0:communicatievoorkeur>
<ns0:overeenkomsten>
<ns0:overeenkomst>
<ns0:overeenkomstIdentificatie>3000077614</ns0:overeenkomstIdentificatie>
<ns0:begindatum>2013-10-01+02:00</ns0:begindatum>
<ns0:productgroep>ELK</ns0:productgroep>
<ns0:locatie>
<ns0:locatieIdentificatie>5000018162</ns0:locatieIdentificatie>
<ns0:adres>
<ns0:postcode>3561CV</ns0:postcode>
<ns0:huisnummer>10</ns0:huisnummer>
<ns0:straatnaam>Euterpedreef</ns0:straatnaam>
<ns0:plaatsnaam>UTRECHT</ns0:plaatsnaam>
</ns0:adres>
<ns0:aansluitingen>
<ns0:aansluiting>
<ns0:aansluitingIdentificatie>871687400009970233</ns0:aansluitingIdentificatie> - then added a test step properties and created the property 'response'
- then added a test step Groovy Script (retrieved from the XML PArsing instructione site)
def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context )
def holder = groovyUtils.getXmlHolder("Properties#response")
log.info holder.getNodeValue("//ns0:contractrekeningIdentificatie")
log.info holder['//ns0:contractrekeningIdentificatie']
What i've tried so far, using some of the info on the above mentioned pages:
I ger an error: Unexpected end of file after null
Am I on the right track here? Can anyone give a step by step explanation how to achieve this?
Ideally I would like to create the output of all nodes in an structured way so i can paste it into excel. But I would already be very glad if i can extract all the ns0:aansluitingIdentificatie></ns0:aansluitingIdentificatie values from the response. But if i can also get for example the 'contractrekening', the 'adres' associated with this contractrekening and the 'aansluitingIdentificatie' associated with this 'contractrekening' etc etc this would be perfect!
for example:
contractrekening;adres;aansluitingIdentificatie