Reputation: 461
I'm in a Hackathon and we have to use IBM Bluemix technologies. We are all new to NodeJs and IBM Bluemix.
We need to upload this XML (there are also TTL, RDF and N3 formats) in the way to create a db and upload everything into it.
Do you have any suggestion on how to do this?
Upvotes: 1
Views: 640
Reputation: 4964
The following example and code assume you are using Express 3. Express 4 is a little different with body parsing...
Store the JSON in your DB.
app.post("/upload", function (request, response) {
async.waterfall(
[
function (next) {
//where leads is the name of the field from your html page
fs.readFile(request.files.leads.path, next);
},
function (xml, next) {
var json = parser.toJson(xml);
db.insert(json, next)
},
], function (error) {
if (error) {
console.log(error);
response.send(error);
return;
}
response.redirect("/");
}
);
});
Upvotes: 1
Reputation: 1559
Try damn-simple-xml to convert to a JavaScript object. It's easy to use and there is a good example of a simple case here.
Upvotes: 0
Reputation: 211
Personally, I'd :
Upvotes: 2