title: Express API JSON and XML POST request
body: <p>I have a express API which allows json post requests. However, in my scenario, one of my API's needs to accept a XML post body, rather than a JSON one. </p>
  
  <p>So my express app is set fine using: </p>
  
  <pre><code>// Init App
  var app = express();
  
  // BodyParser Middleware
  app.use(bodyParser.json());
  app.use(bodyParser.urlencoded({
      extended: false
  }));
  </code></pre>
  
  <p>And here is an example of my POST api JSON route:</p>
  
  <pre><code>router.post('/', function(req, res, next) {
    defaultPoll.create(req.body, function(err, post) {
      if (err) { console.log(err)
      } else {res.json(post);
    }
    });
  });
  </code></pre>
  
  <p>Which works great when I pass in my json values e.g. this is my Post request:</p>
  
  <pre><code>{
      "milliseconds":"600"
  }
  </code></pre>
  
  <p>But now I have an API where I want to do a POST request, but my POST request needs to be send of as XML. So this is what my API looks like:</p>
  
  <pre><code>router.post('/test', function(req, res) {
      var body = req
      console.log(body)
  });
  </code></pre>
  
  <p>Nothing complicated as im not getting anything back. This is how I do the POST request:</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;methodCall&gt;
     &lt;methodName&gt;myMethod&lt;/methodName&gt;
      &lt;params&gt;
        &lt;param&gt;
           &lt;value&gt;&lt;string&gt;hello&lt;/string&gt;&lt;/value&gt;
        &lt;/param&gt;
     &lt;/params&gt;
  &lt;/methodCall&gt;
  </code></pre>
  
  <p>However, my body comes back empty. Any idea how I can fix this? Ideally, I would like to take this XML request, and then respond with an XML of my choice too. What is the best way to do this?</p>
  
  <p>Take the request, convert into JSON, write JSON response and convert back to a XML response?</p>
  
  <p>Any help will be appreciated! </p>