Estoy tratando de devolver el valor del resultado de parseString. Puedo consolar el resultado de registro pero el valor de retorno no está definido. Estoy tratando de analizar el xml y asignar cada valor a una variable. Vi algunas de las publicaciones anteriores con async/await que se usa para llamar a la función processResult pero eso no funcionó. Cualquier ayuda es apreciada.
import readXMLFile from '../readFile.js'; import * as xml2js from 'xml2js'; import * as util from 'util'; const xmlsourcedata = readXMLFile('./src/helpers/parserXML/00a03_e.xml'); //console.log(xmlsourcedata); var stripNS = xml2js.processors.stripPrefix; const parserOpts = { async: true, normalize: true, normalizeTags: true, explicitArray: false, explicitRoot: false, strict: false, xmlns: false, tagNameProcessors: [stripNS] }; const processResult = (xml) => { try { var parser = new xml2js.Parser(parserOpts); parser.parseString(xml.toString(), function(err,result) { //console.log(JSON.stringify(result)); console.log(util.inspect(result, false, {depth: null})); return result; }); } catch (error) { console.error(`Got processing error ${error.message}`); } } processResult(xmlsourcedata);```