usebruno / bruno

Opensource IDE For Exploring and Testing Api's (lightweight alternative to postman/insomnia)
https://www.usebruno.com/
MIT License
27.66k stars 1.28k forks source link

Support xpath and xmldom as an inbuilt library #247

Open helloanoop opened 1 year ago

helloanoop commented 1 year ago

Currently Bruno supports these inbuilt libraries - https://docs.usebruno.com/scripting/inbuilt-libraries.html

You can today do an npm install xpath xmldom at the root of your collection folder and do then do this inside your scripts

const xpath = require('xpath');
const dom = require('xmldom').DOMParser;

const doc = new dom().parseFromString(res.body, 'text/xml');
const query = "//*[local-name()='AuthToken']/text()";
const token = xpath.select(query, doc)[0].nodeValue;

bru.setVar("token", token);

I think xpath and xmldom are great package candidates to support as an inbuilt library.

thirdconspiracy commented 5 months ago

My prerequest script returns xml but I can't easily parse it. Xml support would really help!