XML : How to parse XML from URL with node-xml2js

I am using node-xml2js to parse XML. I am having trouble parsing XML from a URL. I've used this SO answer as a model. But when I use the code below, I get null as the result. Any thoughts on what I'm doing wrong?

  var eyes = require('eyes');  var https = require('https');  var fs = require('fs');  var xml2js = require('xml2js');  var parser = new xml2js.Parser();    parser.addListener('end', function(result) {    eyes.inspect(result);    console.log('Done.');  });    https.get("https://example.com/info.xml", function(result) {    result.on('data', function (data) {      parser.parseString(data);      });    }).on('error', function(e) {    console.log("Got error: " + e.message);  });    

No comments:

Post a Comment