Skip to content

Instantly share code, notes, and snippets.

@arafathusayn
Created March 3, 2021 09:52
Show Gist options
  • Save arafathusayn/cd005338ccaf4c0f3b0c41d6a2460ebd to your computer and use it in GitHub Desktop.
Save arafathusayn/cd005338ccaf4c0f3b0c41d6a2460ebd to your computer and use it in GitHub Desktop.
Postman Test Script - Parse XML API response & set environment variables from the parsed data
var parseString = require("xml2js").parseString;
var xml = pm.response.text();
parseString(xml, (err, data) => {
if (err) throw err;
// traverse and set env variable
pm.environment.set("ENV_NAME_HERE", data.whatever);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment