Trying to remove CDATA from response not working
Hi All,
I am hoping someone can help me here!
I have have a REST request that is returning a response, which seems to be in JSON format. I don't know much about JSON at all.
I can see the XML response also, which contains the "<![CDATA[" tag.
I want to remove the CDATA tag, so that I can use the "Outline" tab to extract necessary data from the response.
I am using an event handler to replace all; in order to remove the tag but it isn't removing it.
The strange part of this is, when I try and remove any other text, that text is removed, which proves the event handler is working.
It just won't remove the CDATA tag.
Any help would be greatly appreciated!
I will attach a snip of the XML tab, and also the code I have in the event handler is below.
The event handler is "RequestFilter.afterRequest"
def content = context.httpResponse.responseContent content = content.replaceAll( "<!\\[CDATA\\[", "" ) log.info( content ) context.httpResponse.responseContent = content |
Thanks in advance.
Steven.
Oh yes sure!
So the response was returned in JSON; which contained 3 nodes.
The 2nd node contained the XML I needed to extract my necessary data; called "suite_id"
I set up a property called "XMLData"; and a property transfer.
I used the Property Transfer "wizard" to select the 2nd JSON node, via the XPATH path language.
I transferred this to the XMLData Property; so this now contains the XML response.
From here I set up a new property, "SuiteID", and another property transfer.
Using the new property transfer, I was able to extract the SuiteID data from the XMLData property. Again using the XPath language in the property transfer wizard.
I transferred the data to my "SuiteID" property.