Created
March 3, 2021 09:52
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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