Hi @vaibhavbarmkar,
Is this the entire response of your API call? If so, I can replicate the problem, and I understand why it is happening; XML documents are supposed to only have a single root node, and this is why xml2json
only parses the first object that it encounters. (I see the same problem when I try to use xml2js
as well.)
I think the best way to resolve would be to pad your response to include a parent tag, for instance:
jsonObject = xml2Json("<myData>" + pm.response.text() + "</myData>");
console.log(jsonObject);
Now I see all three nested items are correctly parsed:
You can then access individual items, e.g.
console.log(jsonObject.myData.data[0].$.name)