Hi doooit
whoops - sorry - it took me that long to type this out that Radford typed out his answer first - so I don't know if this helps at all (it doesn't if you want the groovy option)
there's multiple options for extracting values from a response - groovy script or the OOB functionality - which resolves points 1 and 2 - but can you explain exactly what you're trying to do and flesh out your point 3 requirement please? This will then assist in people tailoring the relevant answer.
If you just need to extract the values of certain tags for later use - here's one option - which is using the OOB property transfer functionality to store in a Properties test step - allowing you to 'store' the values for later use in your test.
Possible Answer to Point 1 (extract Parent Name tag value)
Here's how I would grab your parent name tag value
In the 'Outline' tab, highlight the parent name attribute you want (//body/parent/property/name) and click on 'transfer to' button
Select 'Add Properties step', click on 'Ok' on dialogue to accept name of properties step
click on 'Ok' on 'Create target property' dialogue (to set the name of the property)
'Transfer to Property' form launches - just click 'OK' to accept the defaults for now to create the Property Transfer step.
I then ensure the sequence of the steps is correct - so that the Property Transfer step is AFTER the step that generated your XML response and the Properties step is after your Property Transfer step (so your step hierarchy in the test is as follows):
Test Suite
Test Case
Rest Request
Property Transfer (1 property transfer, transfers the Parent name value to the Properties step)
Properties (contains the Parent name tag value)
The above stores your parent's name tag value in the Properties step - for later use.
At this point, I would then repeat the above (changing the sequence slightly to grab the Parent's id tag value as follows:
Continuation of Possible Answer to Point 1 (extract Parent id tag value)
In the 'Outline' tab, highlight the parent id tag you want (//body/parent/id) and click on 'transfer to' button
Select the 'Properties' step in the menu -
Click on 'Create new'
Click on 'Ok' on 'Create target property' dialogue (to set the name of the property)
'Transfer to Property' form launches - just click 'OK' to accept the defaults for now.
Double click on the 'Property Transfer' step in your test case, look at the 'Target' section - the 'Property' field is blank (in v2.4.0) - so you need to set this property to the one created a couple of steps ago
At this point - I double check if the property transfer runs correctly for each (both) property transfers - to do this I highlight the first property, then I click the green right arrow (alt text = ''Runs selected Property Transfer') and you can see the value successfully captured in the 'Transfer Log' area of the screen - i do this for each property..
A final check is to run your test to ensure the property transfers work on execution and once the test has run - you should be able to see the 2 properties written to the 'Properties' test step also.
So your hierarchy then looks like this
Test Suite
Test Case
Rest Request
Property Transfer (2 property transfers, transfers the Parent name, and Parent id value to the Properties step)
Properties (contains the Parent name and id tag values in 2 properties that were created)
Continuation of Possible Answer to Point 1 (extract Child id tag value)
** repeat 'Continuation of Possible Answer to Point 1 (extract Parent id tag value)' steps but start off with the child id tag instead of the Parent id tag
In regards to an answer to Point 2 - could you please provide the content of the request that needs to be populated with the first child's id tag value (from the response of first request)? It will help in answering your question.
In regards to an answer to Point 3 - if you can provide more info about exactly what you need - that can only help people.
cheers,
richie