4 Replies Latest reply on Apr 9, 2018 5:52 AM by srikanth pantula

    XML data parsing

    srikanth pantula Active Member

      I have an xml data like below, In ICRT i want to take Country as input and want to check against this data and return the corresponding country code, i want to run this process on cloud server so i don't want to take it as file. any suggestions will be appreciated.

       

      <countryMap>

                     <countries>

                                    <code>AD</code>

                                    <country>Andorra</country>

                     </countries>

                     <countries>

                                    <code>AE</code>

                                    <country>United Arab Emirates</country>

                     </countries>

                     <countries>

                                    <code>AF</code>

                                    <country>Afghanistan</country>

                     </countries>

                     <countries>

                                    <code>AG</code>

                                    <country>Antigua and Barbuda</country>

                     </countries>

                     <countries>

                                    <code>AI</code>

                                    <country>Anguilla</country>

                     </countries>

      </countryMap>

        • 1. Re: XML data parsing
          Eishwar Anand New Member

          You can try below options -

           

          > Hard code these values if you don't want to store it in a file. This will be feasible only if you have small amount of data.

           

          >If your only concern is to run process on cloud, then store the file on agent and create a process which runs on agent and reads the file. Later in your main process you can use this process as a sub-process and use it.

           

          >If you don't want to use agent at all, then store this data in some cloud platform or drive which has API access and built a service connector around it and use it in your process.

          • 2. Re: XML data parsing
            Eishwar Anand New Member

            You can also store store the whole xml in a variable and later to fetch the country code you can use xquery and by looping and if condition you can get desired country code by providing country name. This option will hold good if input is not dynamic.

             

            Below is a sample xquery for your use case -

             

            for $x in $temp.inp//countries

            return if ($x/country/text() = $input.country)

            then <ccode>{$x/code/text()}</ccode>

            else()

             

            Here 'inp' is the variable which contains whole xml.

            • 3. Re: XML data parsing
              Prakash Jain Guru

              Hi Srikanth,

               

              Please let me know if your queries are resolved ? if so, can you mark it as answered ?

               

               

              Thanks,

              Prakash Jain

              • 4. Re: XML data parsing
                srikanth pantula Active Member

                Thanks Anand for the solution.It worked..