cancel
Showing results for 
Search instead for 
Did you mean: 

extract xml node value from a response in script assertion

SOLVED
New Member

extract xml node value from a response in script assertion

Hi All

 

Hi have a xpath match assertion that is working perfection as below

declare namespace ns1='http://${#Project#EndpointIP}/Subscription/V1/${DataSource#id_Request}';

//ns1:ATTRIBUTES//child::ns1:NAME [text() = ‘Result']//following-sibling::ns1:VALUE

 

Now I want to convert it to script typed assertion, the value of Result node is stored in variable named addResult as below

 

The problem I have here is that the addResult is always null.  And the assertion is always false.  Not sure why.  Can anyone help me to show where it is wrong?

 

Here is my code

def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context )
def responseHolder = groovyUtils.getXmlHolder( messageExchange.responseContentAsXml.toString())
responseHolder.namespaces["ns1"] = "http://" + context.expand("Project#EndpointIP") + "/SUBSCRIBER/V1/" + context.expand( '${DataSource#id_Request}' )
def addResult = responseHolder.getNodeValue("//ns1:ATTRIBUTES//child::ns1:NAME [text() = ‘Result']//following-sibling::ns1:VALUE")

if (addResult == context.expand( '${DataSource#IDRequest_RESPONSE}' )){
        log.info "matching here ->" + addResult
        assert true
}else{
       log.info "Not matching here ->" + addResult
       assert false
}

 

1 ACCEPTED SOLUTION

Accepted Solutions
Community Manager

Re: extract xml node value from a response in script assertion

@natashanguyen42, I see you contacted the Support Team, and they are waiting for additional info from you. Please share the solution with us when you have it Smiley Happy

Thank you!



Sonya Mihaljova
Community and Education Specialist
Enroll at the SmartBear Academy today and learn our products via exclusive video courses.

View solution in original post

3 REPLIES 3
Community Hero

Re: extract xml node value from a response in script assertion

Would you please show the sample response and same structure (need not be actual) and what value to be extracted?


Regards,
Rao.
Highlighted
Community Manager

Re: extract xml node value from a response in script assertion

nmrao, thanks for your willingness to help! 

 

@natashanguyen42 , are you still facing this issue? If you are, please provide more details so the Community has more information to work with and we will try to help you. 

 

 



Sonya Mihaljova
Community and Education Specialist
Enroll at the SmartBear Academy today and learn our products via exclusive video courses.
Community Manager

Re: extract xml node value from a response in script assertion

@natashanguyen42, I see you contacted the Support Team, and they are waiting for additional info from you. Please share the solution with us when you have it Smiley Happy

Thank you!



Sonya Mihaljova
Community and Education Specialist
Enroll at the SmartBear Academy today and learn our products via exclusive video courses.

View solution in original post

New Here?
Join us and watch the welcome video:
Watch the new Interview
Top Kudoed Authors