Created
October 11, 2013 21:04
-
-
Save jasonrhodes/6942015 to your computer and use it in GitHub Desktop.
Trying to read XML from a search API and convert it to JSON.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var http = require('http'); | |
var xmld = require('xml2js'); | |
var express = require('express'); | |
var app = express(); | |
// app.use(express.static(__dirname + '/public')); | |
app.get("/", function (req, res) { | |
var options = { | |
hostname: "search.mysite.com", | |
path: '/search?site=hub&client=hub_frontend&output=xml_no_dtd&q=cats' | |
}; | |
var gsaReq = http.get(options, function (response) { | |
response.on('data', function (chunk) { | |
console.log(chunk); | |
// xmld.parseString(chunk, function (err, result) { | |
// if (err) console.log("ERROR", err); | |
// console.log('my resultsult', result); | |
// }); | |
}); | |
}).on('error', function (e) { | |
console.log('problem with request: ' + e.message); | |
}); | |
}); | |
app.listen(3000); |
psi-4ward
commented
Oct 11, 2013
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment