Ask a Question

[RESOLVED] extract data from nodes depending on the condition

Usha_Kodali
Frequent Contributor

[RESOLVED] extract data from nodes depending on the condition

Hi,
In the below response, I want to search for Commentary and then if I find it assert that its commentary and then extract ID,SpotID and then  i need to pass as input to another request
I have such nodes with variety other than commentary and there could be more than one commentary elements with different ID and SpotID.


                  4
                 
                     

                     true
                     
                 

                 
                  2009-10-15T16:00:53.3833256-04:00
                 
                  2009-10-15T16:00:53.3833256-04:00
                  faceoff_u3rd_logo_1
                 
                     
                        1
                        18
                        commentary ------- This is what i need to assert.
                        logo_soundoff_1
                     

                 

                  1
                  Primary
                  83
                  -40
                  83
                  190
                  107
                  1
               


Attaching the whole response
15 REPLIES 15
Usha_Kodali
Frequent Contributor

if you guys want whole response i can email you
SmartBear_Suppo
SmartBear Alumni (Retired)

Hello,

Hm...You should use groovy test step to extract all values you need ( id, spotId ) and put them all in property at test case level, check this: http://www.soapui.org/userguide/functional/groovystep.html. Than you should use property transfer step(http://www.soapui.org/userguide/functional/propertytransfers.html) or groovy step to go trough extracted values and set parameters for request.

Hope this helps, let me know
robert

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
Usha_Kodali
Frequent Contributor

got this working....

spotID = holder.getDomNodes("//aetgt:GetSpotListsResult/aetgt:spotlists/aetgt:Spotlist/aetgt:Spots/aetgt:Spot[aetgt:Variety='commentary']/aetgt:SpotID")
spotListID = holder.getDomNodes("//aetgt:GetSpotListsResult/aetgt:spotlists/aetgt:Spotlist/aetgt:Spots/aetgt:Spot[aetgt:Variety='commentary']/../../aetgt:ID")

once we get nodes based on the condition we need to getvalue using getNodeValue.
Usha_Kodali
Frequent Contributor

I got the spotID and ID using the above steps.
I have spotID = [1,1]
SpotListID = [4,5]

How do i pass these to datasource from the groovy script result? I want to loop on SpotListID.
SmartBear_Suppo
SmartBear Alumni (Retired)

Hi Usha,

if you want you create a DataSource/DataSourceLoop construct from values in a message response, try the XML DataSource which allows you to do just that using xpath expressions for row / property selection.

Does that help?

regards!

/Ole
eviware.com

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
Usha_Kodali
Frequent Contributor

Hi Ole,
I am getting values using XML Datasource.
But the result looks likes this.

ID                  SpotID
4
5
                          1
                          1

But my expected result should be

ID              SpotID
4                  1
5                  1

How to achieve the above result?

my rowpath expression is

declare namespace aetgt='http://musicchoice.com/services/games';
//aetgt:GetSpotListsResult/aetgt:spotlists/aetgt:Spotlist/aetgt:Spots/aetgt:Spot[aetgt:Variety='commentary']/../..,
//aetgt:GetSpotListsResponse/aetgt:GetSpotListsResult[1]/aetgt:spotlists/aetgt:Spotlist/aetgt:Spots/aetgt:Spot[aetgt:Variety='commentary']

column path expression is

aetgt: ID/text()
aetgt: SpotID/text()
SmartBear_Suppo
SmartBear Alumni (Retired)

Hi!

hmm.. can you attach the corresponding response message?

regards,

/Ole
eviware.com

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
Usha_Kodali
Frequent Contributor

attached the complete response
SmartBear_Suppo
SmartBear Alumni (Retired)

Try doing something like this:

rowpath:
declare namespace aetgt='http://musicchoice.com/services/games';
//aetgt:GetSpotListsResult/aetgt:spotlists/aetgt:Spotlist/aetgt:Spots/aetgt:Spot[aetgt:Variety='commentary']/../..

columnpath:
aetgt: ID/text()
aetgt:Spots/aetgt:Spot/aetgt: SpotID/text()

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
cancel
Showing results for 
Search instead for 
Did you mean: