Closed jgravois closed 7 years ago
figured it out!
const request = require('request')
const iconv = require('iconv-lite')
const parseString = require('xml2js').parseString
request({
uri: 'https://walmart.alertlink.com/rss/stores.rss',
gzip: true,
encoding: null,
headers: {
"Accept-Encoding": "gzip, deflate, br"
}
}, (err, res, body) => {
if (err) return callback(err)
// response is encoded as utf16. who knew?!?
// i sure didn't. i barely understand what that even means!
const rss = iconv.decode(new Buffer(body), "utf16");
parseString(rss, function (err, result) {
console.log(result)
})
})
I feel like i'm close with this Walmart provider to help the disaster response team but I’m having trouble parsing the .xml returned by the feed.
Initially, there were a couple bogus characters at the beginning of the body that needed trimmed. Afterward, even though the input looked valid, the strict xml2js/sax-js parser complained
stepping through that code i realized it is choking on
""
characters between the characters that are actually visible in the browser developer toolsexample:
for the moment, i'm stumped.
@nixta @dmfenton @tomtom92 if any of you are interested/available to take a look, it should be as straightforward as
npm install && npm start