title: Parsing with xml2js
body: <p>I am new to <code>node.js</code> and need to parse <code>XML</code>. In js, I just use a <code>DOMParser</code> and use <code>getElementsByTagName</code> to get the values I desire. I have just switched to node and am using <code>xml2js</code> (willing to consider alternatives). I have not been able to figure out how to parse through the response to get what I am looking for.</p>
  
  <p>Code below:</p>
  
  <pre><code>function parseBody(body){
      var parseString = require('xml2js').parseString;
      var xml = body
      parseString(xml, function (err, result) {
      console.dir(result);
  });
  </code></pre>
  
  <p>and here is the XML I am passing into the function: </p>
  
  <pre><code>&lt;soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:int=\"realURLHere"&gt;
     &lt;soapenv:Header/&gt;
     &lt;soapenv:Body&gt;
        &lt;int:readResponse&gt;
           &lt;response&gt;
              &lt;request&gt;?&lt;/request&gt;
              &lt;cust&gt;
                 &lt;fName&gt;?&lt;/fName&gt;
              &lt;/cust&gt;
          &lt;/response&gt;
        &lt;/int:readResponse&gt;
     &lt;/soapenv:Body&gt;
  &lt;/soapenv:Envelope&gt;
  </code></pre>
  
  <p>Here is the output of my function:</p>
  
  <pre><code>{ 'soapenv:Envelope':
     { '$':
        { 'xmlns:soapenv': 'http://schemas.xmlsoap.org/soap/envelope/',
          'xmlns:int': 'realURLHere' },
       'soapenv:Body': [ [Object] ] 
     } 
  }
  </code></pre>
  
  <p>I am trying to access the value of <code>&lt;fName&gt;</code> within <code>&lt;cust&gt;</code> but having no luck. Any help would be appreciated. Thanks! </p>