Forum Discussion

jsreesoap's avatar
jsreesoap
Contributor
12 years ago

How to read xml nodes one by one and store

I get xml in response as shown below:
<Response>
<e>1234</e>
<e>5678</e>
<e>12599</e>
<e>4545445</e>
</Response>

I need to read each value and store it in a property/variable so that I can call one by one in my other script. The values are dynamic, next time I run it I may get only 4 values or 20 and the numbers also change. Pls let me know if there is a way to do it. I am sure there is one but I don't know :-)
Thanks

5 Replies

  • Thanks for the reply but I am not using datasource. The response comes from our database as the API is executed.
  • Hi,

    Use the event handler RequestFilter.afterRequest with the code below to write the response to a file as XML and then use a data source to read the file.


    File file = new File("C:\\write_response.xml")
    file.text = context.httpResponse.getContentAsXml()



    Regards,
    Marcus
    SmartBear Support
  • Is this the only available option? I am trying to eliminate the need of external files for data. Can I use any java code in the script?
  • SiKing's avatar
    SiKing
    Community Expert
    jsreesoap wrote:
    Thanks for the reply but I am not using datasource. The response comes from our database as the API is executed.

    DataSource is one of the steps in SoapUI. Have a read through the link I supplied above.