Virgin_Australi_1
14 years agoNew Contributor
Add XML elements based on Datasource
Hello,
I have an xml request which creates flight bookings. As standard, there is one flight attribute and one passenger attribute. This is fine for creating one flight, with one passenger. However for creating a multi flight booking, I need two flight elements. I can't have these as standard in the request as I can't send empty values (which I would be if it were a single flight).
So, my aim is that perhaps a groovy script (?) could check my datasource (excel file) to see how many flights / passengers I'm trying to create, and then add these into the xml request. However I have never done scripting of any kind before, and so have no idea where to start. I'm also hoping maybe theres an alternative to build up these elements without scripting?
Sample of the part of the xml I would like to add to (depending on the datasource)...
<passengers>
<!--You have a CHOICE of the next 3 items at this level-->
<child>
<!--You may enter the following 13 items in any order-->
<!--Optional:-->
<title>${DataSource#title1}</title>
<!--Optional:-->
<!--Optional:-->
<firstName>${DataSource#firstname1}</firstName>
<!--Optional:-->
<lastName>${DataSource#lastname1}</lastName>
<flights>
<!--Zero or more repetitions:-->
<flight><ssrs><ssr>${DataSource#ssr1}</ssr></ssrs></flight></flights>
</child>
</passengers>
<flights>
<!--You have a CHOICE of the next 2 items at this level-->
<flight>
<!--You may enter the following 3 items in any order-->
<bookingKey>${getavailabilityonelfight#Response#declare namespace ns2='http://www.virginblue.com.au/schema/2005/02/booking.xsd'; //ns2:getAvailabilityResponse[1]/availability[1]/flights[1]/availableFlight[1]/fares[1]/fare[1]/bookingKey[1]}</bookingKey>
<!--Optional:-->
<priority>Confirmed</priority>
<!--Optional:-->
</flight>
Thanks in advance
James
I have an xml request which creates flight bookings. As standard, there is one flight attribute and one passenger attribute. This is fine for creating one flight, with one passenger. However for creating a multi flight booking, I need two flight elements. I can't have these as standard in the request as I can't send empty values (which I would be if it were a single flight).
So, my aim is that perhaps a groovy script (?) could check my datasource (excel file) to see how many flights / passengers I'm trying to create, and then add these into the xml request. However I have never done scripting of any kind before, and so have no idea where to start. I'm also hoping maybe theres an alternative to build up these elements without scripting?
Sample of the part of the xml I would like to add to (depending on the datasource)...
<passengers>
<!--You have a CHOICE of the next 3 items at this level-->
<child>
<!--You may enter the following 13 items in any order-->
<!--Optional:-->
<title>${DataSource#title1}</title>
<!--Optional:-->
<!--Optional:-->
<firstName>${DataSource#firstname1}</firstName>
<!--Optional:-->
<lastName>${DataSource#lastname1}</lastName>
<flights>
<!--Zero or more repetitions:-->
<flight><ssrs><ssr>${DataSource#ssr1}</ssr></ssrs></flight></flights>
</child>
</passengers>
<flights>
<!--You have a CHOICE of the next 2 items at this level-->
<flight>
<!--You may enter the following 3 items in any order-->
<bookingKey>${getavailabilityonelfight#Response#declare namespace ns2='http://www.virginblue.com.au/schema/2005/02/booking.xsd'; //ns2:getAvailabilityResponse[1]/availability[1]/flights[1]/availableFlight[1]/fares[1]/fare[1]/bookingKey[1]}</bookingKey>
<!--Optional:-->
<priority>Confirmed</priority>
<!--Optional:-->
</flight>
Thanks in advance
James