Contributions
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, Oct211KViews0likes1CommentRe: Need to extract the value of an attribute from response XML
Hinmrao 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, Oct211KViews0likes3CommentsRe: Need to extract the value of an attribute from response XML
nmrao I tried below code to save my response xml. In my case response xml will always generate new OrderRef. def groovyUtils = new com.eviware.soapui.support.GroovyUtils(context) def str = groovyUtils.getXmlHolder("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) } But am getting error. Could you please check? Thanks, Oct212.5KViews0likes8CommentsNeed to extract the value of an attribute from response XML
Hi I want to extract the value oforderItemRef from both assessment and report tag from response XML <AssessmentOrder> <Assessment packageTag="A_VAT_Induct" name="Verify - Inductive Reasoning (2007)" orderItemRef="2183404" 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="1711998" language="en-US" comparisonGroup="" reportFormat="Pdf" reportMedia="Link"/> <AssessmentAccess hasAssessments="true"> <Assessment stage="1"> </Assessment> </AssessmentAccess> </AssessmentOrder> Please help. Thanks Oct213.1KViews0likes13CommentsRe: Getting error "content is not allowed in prolog" while parsing XML through groovy scripts
nmrao I tried to use the script as script assertion to the request where i am getting the response. But i am getting the same error. Not sure what has changed, it is parsing the values but not able to pick the one which is described. And the past script i used as a groovy script and worked perfectly. Could please check and help me again. Check the screenshot. Thanks again. Regards, Oct218.4KViews0likes3CommentsGetting error "content is not allowed in prolog" while parsing XML through groovy scripts
Hi Am using groovy script to parse the XML. Am able get all the data nodes but not able to fetch the particular which i want. Code assert context.response def getData = { data, element -> new XmlSlurper().parseText(data).'**'.find {it.name() == element} } def inXmlStr = getData(context.response, 'Acknowledge').text() log.info inXmlStr def receiptId = getData(inXmlStr, 'ReceiptId') log.info receiptId context.testCase.setPropertyValue('ID', receiptId.IdValue.toString()) Response XML : <?xml version="1.0" encoding="utf-8"?> <AcknowledgeCandidateRegistration majorVersionId="1" minorVersionId="0" xmlns="http://cebtalentcentral.com"> <ApplicationArea> <CreationDateTime>2019-02-12T15:11:05.027Z</CreationDateTime> </ApplicationArea> <Acknowledge> <OriginalApplicationArea> <CreationDateTime>2019-02-12T15:11:03.470Z</CreationDateTime> </OriginalApplicationArea> <ReceiptId>155785</ReceiptId> // need this particular id <Status>Completed</Status> <RejectCode>0</RejectCode> <RejectReason /> </Acknowledge> </AcknowledgeCandidateRegistration> Regards, Oct21Solved8.5KViews0likes7Comments