Leonidas-from-XIV/node-xml2js — Issue #41: Can't use a singleton parser object
Author: ssssssssssss
Created: 2011-11-25 11:36:44+00:00
State: open

My web application goes like this:
```javascript
var xml2js = require('./xml2js/lib/xml2js');
var parser = new xml2js.Parser({
trim:false,
normalize:false
});
```
And in express router:
```javascript
app.get('/fd/:api', function(req, myResponse, next)
{
http.get({path..host...port}, function(res)
{
var data = '';
res.setEncoding('utf8');
res.on('data', function(chunk)
{
data += chunk;
});
res.on('end', function()
{
if (res.statusCode == 200)
{
parser.parseString(data, function (err, result)
{
myResponse.contentType('application/json');
myResponse.send(err ? { success:false } : result);
myResponse.end();
});
}
});
});
})
```
For the second request, it will throw error. But if I new xml2js.Parser() when statusCode == 200. everything works fine.