cancel
Showing results for 
Search instead for 
Did you mean: 

Need to extract the value of an attribute from response XML

Oct21
Occasional Contributor

Re: Need to extract the value of an attribute from response XML

Hi @nmrao 

I tried the updated reponse response, and this too throwing error. It is working fine with fixed xml.

def groovyUtils = new com.eviware.soapui.support.GroovyUtils(context)
def str = context.expand('{RegistrationRequest#Response}')
def xml = new XmlSlurper().parseText(str)
def getOrderRef = { element ->
xml.'**'.find {it.name() == element}.@orderItemRef
}

def elements = ['Assessment', 'Report']
elements.each { log.info getOrderRef(it) }

See the screeshot for error.

 

Thanks,

Oct21

nmrao
Community Hero

Re: Need to extract the value of an attribute from response XML

Error is nothing to do with script. You need to check what response have you got.


Regards,
Rao.
Oct21
Occasional Contributor

Re: Need to extract the value of an attribute from response XML

This is the complete response xml. Can you please help me with this.

<?xml version="1.0" encoding="utf-8"?>
<AcknowledgeCandidateRegistration majorVersionId="1" minorVersionId="0" xmlns="http://cebtalentcentral.com">
  <ApplicationArea>
    <CreationDateTime>2019-03-27T12:36:41.200Z</CreationDateTime>
  </ApplicationArea>
  <Acknowledge>
    <OriginalApplicationArea>
      <CreationDateTime>2019-03-27T12:36:40.903Z</CreationDateTime>
    </OriginalApplicationArea>
    <ReceiptId>159803</ReceiptId>
    <Status>Completed</Status>
    <RejectCode>0</RejectCode>
    <RejectReason />
  </Acknowledge>
  <DataArea>
    <AssessmentOrder>
      <Assessment packageTag="A_VAT_Induct" name="Verify - Inductive Reasoning (2007)" orderItemRef="2226954" language="MULTI" stage="1" jobLevel="Graduate/University" originalTimer="00:25:00" adjustedTimer="00:25:00" />
      <Report packageTag="A_VAT_Induct" name="Verify - Inductive Reasoning (2007)" orderItemRef="1749160" language="en-US" comparisonGroup="" reportFormat="Pdf" reportMedia="Link" />
      <AssessmentAccess hasAssessments="true">
        <Assessment stage="1">
          <AssessmentCommunication>
            <URI>https://integration-talentcentral-qa2.eu.shl.com/integration/ce/b402bc945d264937b9edd9e251597ee0/?rid=159803</URI>
          </AssessmentCommunication>
        </Assessment>
      </AssessmentAccess>
    </AssessmentOrder>
  </DataArea>
</AcknowledgeCandidateRegistration>

Thanks,

Oct21

nmrao
Community Hero

Re: Need to extract the value of an attribute from response XML

Have you tried the script with above xml ?
When you get the error, what does it show in the raw response ?


Regards,
Rao.
New Here?
Join us and watch the welcome video:
Top Kudoed Authors