Advertisement
Adam_Martin

Untitled

Nov 29th, 2012
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. app.post('/timesheets', function(req, res) {
  2.  
  3.   var file = req.files.data;
  4.   var fileBody = fs.readFileSync(file.path).toString();
  5.  
  6.   var xml = new Buffer(fileBody, 'base64').toString();
  7.   xml = xml.replace(/<\?.*\?>/, '');
  8.  
  9.   var json = xml2json.parser(xml);
  10.  
  11.   mongo.collection('lol').insert(json.root);
  12.  
  13.   mongo.collection('lol').find({
  14.     'dept': {
  15.       $exists: true
  16.     }
  17.   }, {
  18.     _id: 0
  19.   }).toArray(function(err, result) {
  20.     xml = json2xml.toXml("root", result[0]);
  21.     xml = new Buffer(xml, 'utf8').toString('base64');
  22.     res.contentType('text/html');
  23.     res.send(xml);
  24.   });
  25.  
  26. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement