Forum Discussion

ashkht's avatar
ashkht
Contributor
7 years ago

To find xpath of element from XML response after removing CDATA

Hello All,

I am trying to find xpath of an output element from XML response which is been retrieved by removing CDATA tags after using following code under Event - "SubmitListener.afterSubmit".

if( submit.response == null )
return
def responseContent = submit.response.responseContent
responseContent = responseContent.replaceAll( "<!\\[CDATA\\[", "" )
responseContent = responseContent.replaceAll( "]]>", "" )
log.info( responseContent )
submit.response.responseContent = responseContent

 

Sample Response:

 

<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<ExecuteSearchResponse xmlns="http://www.valuecheckonline.com/">
<ExecuteSearchResult><?xml version='1.0' encoding='utf-8'?>

 

 


<ValueCheck>
<FindTargetProperty>
<State>CO</State>
<County>ELPA</County>
<OwnerName>BULLOCK, MARYLN</OwnerName>
<Address>1523 LOOKOUT SPRINGS DR</Address>
<City>Colorado Springs</City>
<Zip>80921</Zip>
</FindTargetProperty>
</ValueCheck></ExecuteSearchResult>
</ExecuteSearchResponse>
</soap:Body>
</soap:Envelope>

 

Now i am trying to figure out xpath which would take me to elememt - City. I tried using xpath expression , but the problem after we extract information from CDATA using above event, in xpath tree, we do not find any respective nodes for each of element. Can you please assist me on the same. Please find below snippet attached from SOAP UI Pro. 

If need to find out via groovy script, even using "GetData" option doesnt point to desired o/p element as nodes are not available in xpath/xml tree.

 

Regards,

Ashish

2 Replies