Forum Discussion

MRAO's avatar
New Contributor
7 years ago

How to append a Tag in a existing XML as per count increases Dynamically through Data source

I have a requirment where i need to dynamically increase/append the tag as the count increases




5 Replies

  • JHunt's avatar
    Community Hero

    Are you referring to a SoapUI Pro DataSource? If you are, please move your post to the SoapUI Pro forum.


    Otherwise, please be specific:


    What is the XML you want to update? (Post the real thing or a modified example that we can work with).


    When should it be updated?


    What should the result look like, based on the starting XML?

    • MRAO's avatar
      New Contributor

      HI  xml we need to manipulate. it is in soap ui free version only we need to increase the Participantcount tag dynamically using groovy when we give count as per  from csv/excel file


  • JHunt's avatar
    Community Hero

    You can turn a request like this:



    Into one like this:



    Then you just need to build 'participants' with some sort of a loop across all the data.



    String s = ""
    for (Participant p : getParticipants()) {
       s += "<ParticipantCount>${p.age}</ParticipantCount>\n"
    context['participantsAsXml'] = s

    Is that what you meant?

    • MRAO's avatar
      New Contributor

      Hi wasnt able to understand it properly can u please give a detail on it please find updated Request XML


      <InterfaceRQ xmlns="*****">
                     <Credential name="${#TestSuite#CredOne}" isEncrypted="${#TestSuite#Encyp}">${#TestSuite#USERNAME}</Credential>
                        <OperationURL operation="all">${#TestSuite#OperationURL}</OperationURL>
            <ProcessingInformation PricingCurrency="${#TestSuite#PricingCurrency}"/>
                           <CountryName Code="${#TestSuite#CountryName}"/>
                        <Region RegionCode="${#TestSuite#RegionCode}" />
                     <Schedule StartPeriod="${#TestSuite#StartPeriod}" EndPeriod="${#TestSuite#EndPeriod}"/>
                      <Participant Quantity="${#TestSuite#Quantity}" Age="${#TestSuite#Age}">
                        <QualifierInfo Extension="">${#TestSuite#Extension}</QualifierInfo>
                        <!-- Value Can be Adult,Child,Infant -->

      • nmrao's avatar
        Champion Level 3
        In the above xml, there is no "ParticipantCount". Is it missing?