Get Value from single XML parameter

Hi there, not sure if this might be useful to anybody else, but I was looking for a simple method to send along a parameter in an email message, which gets processed via the IMAP Email node. In my case, I wanted to send along the project number via 12345 in the email’s body text. I build a similar Let function in FileMaker ages ago, and copied the logic to JavaScript, as follows:

//let text = "blah, blah, blah, etc. <PROJECT>12345</PROJECT>";
const text = item.text;

const result = [];

let xmlTag = "PROJECT";
let xmlLength = xmlTag.length;

let start = text.indexOf("<" + xmlTag + ">") + xmlLength + 2;
let stop = text.indexOf("</" + xmlTag + ">") ;
let xmlResult = text.substring(start, stop);


return result;