CCHATTERTON
12 years agoOccasional Contributor
[Resolved] CSV File & Multiple Elements With the Same Name
Hi,
I am using a CSV datasource containing multiple rows of data to transfer values into a request. Data is stored in the CSV file similarly to the below example, with several drivers on each row:
Driver1 Name, Driver1 Age Years, Driver 1 Age Months, Driver2 Name, Driver2 Age Years, Driver 2 Age Months, Driver3 Name, Driver3 Age Years, Driver 3 Age Months,
John Smith, 30, 5, Bill Smith, 25, 3, Will Smith, 28, 1,
The request must be in this format:
<drivers>
<driver>
<name>John Smith</name>
<ageyears>30</ageyears>
<agemonths>5</agemonths>
</driver>
<driver>
<name>Bill Smith</name>
<ageyears>25</ageyears>
<agemonths>3</agemonths>
</driver>
<driver>
<name>Will Smith</name>
<ageyears>28</ageyears>
<agemonths>1</agemonths>
</driver>
</drivers>
Obviously if I use a property transfer from the datasource for each driver, with the xpath pointing to the required element e.g. //drivers/driver/name, the values from Driver2 will overwrite what was transferred from driver 1. Is there any kind of workaround I could implement to distinguish between the elements with the same name?
Thanks
I am using a CSV datasource containing multiple rows of data to transfer values into a request. Data is stored in the CSV file similarly to the below example, with several drivers on each row:
Driver1 Name, Driver1 Age Years, Driver 1 Age Months, Driver2 Name, Driver2 Age Years, Driver 2 Age Months, Driver3 Name, Driver3 Age Years, Driver 3 Age Months,
John Smith, 30, 5, Bill Smith, 25, 3, Will Smith, 28, 1,
The request must be in this format:
<drivers>
<driver>
<name>John Smith</name>
<ageyears>30</ageyears>
<agemonths>5</agemonths>
</driver>
<driver>
<name>Bill Smith</name>
<ageyears>25</ageyears>
<agemonths>3</agemonths>
</driver>
<driver>
<name>Will Smith</name>
<ageyears>28</ageyears>
<agemonths>1</agemonths>
</driver>
</drivers>
Obviously if I use a property transfer from the datasource for each driver, with the xpath pointing to the required element e.g. //drivers/driver/name, the values from Driver2 will overwrite what was transferred from driver 1. Is there any kind of workaround I could implement to distinguish between the elements with the same name?
Thanks