Forum Discussion

RJanecek's avatar
RJanecek
Regular Contributor
14 years ago

Create xml element with groovy and use it

Hi,
I wanna load property from data source then in groovy script I wanna create element with this property

element = "<data>" + datafromdatasource  + "</data>"
end then I wanna use this element in my xml.

<Body> [$element] </Body>
something like that I dont remember how I did this . Please help
thx

5 Replies

  • bmgriner's avatar
    bmgriner
    Frequent Contributor
    If I understand you right, you are trying to load data from some datasource and put it in an xml request. Correct me if I'm wrong.

    I think the best way to do this is to right click on the mouse and choose the Get Data option. This should allow you to go through possible options and insert in the script. That script usually looks something like ${}

    ie ${DataSource2#test}

    where DataSource2 is the name of the data source step and test is the name of the column of data.
  • RJanecek's avatar
    RJanecek
    Regular Contributor
    nope . I wanna this property load into groovy script end create element what I know how to do.
    I dont know how this new element insert into request
  • RJanecek wrote:
    nope . I wanna this property load into groovy script end create element what I know how to do.
    I dont know how this new element insert into request

    Sorry, I don't understand what you want to do. Could you perhaps attach a screenshot?

    Best Regards

    Henrik
    SmartBear Sweden
  • RJanecek's avatar
    RJanecek
    Regular Contributor
    ok never mind I just solved it. I created element in groovy script and then set it to context
    context.setProperty( "element", element )
  • Hi, can you please provide some detail on how you did this please?

    I'm using MarkupBuilder in groovy to create some elements, but I don't know how to insert these into an existing request based on Datasource values.

    Thanks
    James