/** * Returns the steam64id of the steam profile * @param communityUrl URL of the steam profile */ static async getSteamIdFromProfile(communityUrl) { let data = await rp(communityUrl); //Parse XML (we need to get the steamID64 tag) let document = new xmldoc.XmlDocument(data); let child = document.childNamed("steamID64"); if(child !== undefined){ return child.val; } return null; }
self.fetchContent(URL, function (err, content) { if (err) { return callback(err, null); } // Parse the content fetch from national bank of romania var xmlObj = self.parseContent(content); var rootCube = xmlObj.childNamed("Body"); var cube = rootCube.childNamed("Cube"); // return error if date is not available if (cube === null || _.isUndefined(cube) || _.isUndefined(cube.attr)) { return callback(new UnsupportedCurrencyPairException(currencyPair, Provider), null); } // search for quote currency rate var rateElement = cube.childWithAttribute('currency', currencyPair.getQuoteCurrency()); // return error if rate is not available if (rateElement === null || _.isUndefined(rateElement) || _.isUndefined(rateElement.attr) || _.isUndefined( rateElement.val)) { return callback(new UnsupportedCurrencyPairException(currencyPair, Provider), null); } var val = Big(rateElement.val); var rate = rateElement.attr.multiplier ? val.div(Big(rateElement.attr.multiplier)) : val; var date = cube.attr.date ? new Date(cube.attr.date) : new Date(); return callback(null, new Rate(rate.toString(), date, Provider)); });
/** * @swagger * * /rest/xml/example1: * get: * summary: Parse XML * tags: * - xml * responses: * '200': * description: Info */ app.get("/rest/xml/example1", (req, res) => { const xml = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <!-- this is a note --> <note noteName="NoteName"> <to>To</to> <from>From</from> <heading>Note heading</heading> <body>Note body</body> </note> </xml>` let body = "" let note = new XmlDocument(xml) note.eachChild((item) => { body += item.val + '</br>' }) return res.type("text/html").status(200).send(body) })