Ask a Question

Search and Replace within XML

smartTest
Contributor

Search and Replace within XML

Hiya

One of my tests requires me to transfer over a large amount of XML from a response message into a new request. When this happens it transfers over the original namespaces as well as the included text/attributes. Does anyone know if there is a way to either:

a) Stop the namespaces being transferred in the Property Transfer
b) Offer another way of transferring a large set of nodes/child nodes so the namespaces are not transferred
c) Script a simple search and replace to amend the namespaces and to include removal of un-necessary xslt's?

Right now, this is a manual process which is taking a long time to complete and means these scripts cannot be automated.

thanks
2 REPLIES 2
RJanecek
Regular Contributor

Hi,

I dont understand why you wanna stop transfering namespace. Without it your xml can be invalid. Can you show here some example
RJanecek
Regular Contributor

You can create groovy script:

// get response
def response = context.expand( '${RequestName#Response}' )
// do some replace
response = response.replaceAll("", "")
// save response as property in tesCase
def tc = testRunner.testCase
tc.setPropertyValue("response",response)


and then in property transfer
source testCase and find this new property
Target: requestName Property Request
cancel
Showing results for 
Search instead for 
Did you mean: