As you can see, the output has Analytics-Cluster listed twice and in such cases, I want to be able to parse them as a list of clusters. If I do normal xml to json, I do not get the value of either one. How do I parse them and get them as a list? In other words, I want to get the values “Clus2” and “suraj-va1” into a list variable.
Thanks,
Suraj
Your question may already have an answer on the community forum. Please search for related topics, and then read through the guidelines before creating a new topic.
This doesn’t look like valid XML since the <name> tag is never closed. I’m not sure what you’re using to generate it but when closing the tag and running the result through XML to JSON converters I’m getting a list of names as expected.
This is the XML I’m using:
Thanks for the response. The Tags were infact closed, but when I copied and pasted it in the support page here, I escaped the first one and not the second one.
Can you provide me a sample test script to get the list of all the names though? For me, when there is single one, I have the variable for the name populated using the test script, but when there are more than one entries in the cluster (resulting in two names in the cluster), I get a blank value assigned.
I’ve created a collection showing how you can generate a list of names based of the XML you shared here. You can import it in Postman by clicking Import -> Import From Link and pasting this: https://www.getpostman.com/collections/d388a2f1c90795155bc6
I’m using the xml2Json that is available by default and then looping through the JSON object to get each name and push it to an array.