title: Promisifying xml2js parse function (ES6 Promises)
body: <p>I'm trying to refactor some node code that is a whole mess of callbacks. I thought that would be nice give promises a try for this purpose. I'm trying to convert some xml string to json with the <code>xml2js</code> node module. The original code was:</p>
  
  <pre><code>"use strict";
  
  var xml2jsParser = require('xml2js').parseString;
  
  var string = "&lt;container&gt;&lt;tag3&gt;option3&lt;/tag3&gt;&lt;/container&gt;";
  
  xml2jsParser(string, function(err, result)
  {
      console.log(result);
  });
  </code></pre>
  
  <p>and this displays:</p>
  
  <pre><code>{ container: { tag1: [ 'option1' ], tag2: [ 'option2' ], tag3: [ 'option3' ] } }
  </code></pre>
  
  <p>Following the first answer on this question <a href="https://stackoverflow.com/questions/22519784/how-do-i-convert-an-existing-callback-api-to-promises?lq=1">How do I convert an existing callback API to promises?</a> I tried to wrap the xml2jsParser function using promises in the following way:</p>
  
  <pre><code>"use strict";
  
  var xml2jsParser = require('xml2js').parseString;
  
  function promisesParser(string)
  {
      return new Promise(function(resolve, reject)
      {
          xml2jsParser(string, resolve);
      });
  }
  
  var string = "&lt;container&gt;&lt;tag3&gt;option3&lt;/tag3&gt;&lt;/container&gt;";
  
  promisesParser(string).then(function(err, result){
      console.log(result);
  });
  </code></pre>
  
  <p>This displays <code>undefined</code> through the console instead of the json object as expected. I don't understand why this happens as I was able to successfully do the same with other functions. I know something similar can be achieved with Bluebird promisify functionality but I'd like to do this on plain Javascript without any third party libraries.</p>