Skip to content Skip to sidebar Skip to footer

Xml2js Read From Url

So I have NodeJS and installed the module xml2js. In the tutorial we have an example taking an xml file from directory and convert it with JSON.stringify() as in the example. Now i

Solution 1:

You need to create an http request instead of reading a file. Something like this, I think:

http.get("http://www.google.com/index.html", function(res) {
  res.on('data', function (chunk) {
    parser.parseString(chunk); 
  });
}).on('error', function(e) {
  console.log("Got error: " + e.message);
});

http://nodejs.org/api/http.html#http_http_request_options_callback

Post a Comment for "Xml2js Read From Url"