What i am doing:: I am trying to generate json and xml output for a dataset from database
Express Code:: Here i am trying for JSON response
So I've looked around for a better object-to-XML mapper for you. I tried three before I found one that I liked (it's easy-to-use, and it makes sense for your application). Ditch the old one, and use object-to-xml instead:
var o2x = require('object-to-xml');
response.set('Content-Type', 'text/xml');
response.send(o2x({
'?xml version="1.0" encoding="utf-8"?' : null,
restaurants: {
restaurant: name_of_restaurants
}
}));