title: How to get XML from array of objects with xml2js?
body: <p>I want to use xml2js to build XML file from array of objects. Is there a way to do it?</p>
  <p>This doen't work because xml2js.Builder() expects a single object.</p>
  <pre><code>export const buildXML = (data: any[]) =&gt; {
    const builder = new xml2js.Builder();
    return builder.buildObject(data)
  }
  </code></pre>
  <p>This returns array of XMLs but I need a single one:</p>
  <pre><code>export const buildXML = (data: any[]) =&gt; {
    const builder = new xml2js.Builder();
    return data.map(obj =&gt; builder.buildObject(obj))
  }
  </code></pre>
  <p>The resulted XML should be used in this function</p>
  <pre><code>export const downloadFile = (data: any[], fileName = 'generator_result', fileFormat: any) =&gt; {
    let parsedData: any
    const FILE_TYPE = fileFormat === 'xml' ? XML_TYPE : EXCEL_TYPE;
    if (fileFormat === 'xml') {
      parsedData = buildXML(data);
    } else {
      parsedData = downloadAsExcel(data, fileFormat)
    }
    const fileData = new Blob([parsedData], {type: FILE_TYPE});
    saveAs(fileData, fileName + '.' + fileFormat);
  }
  </code></pre>
  <p>UPD
  If I do this then nothing happens...I mean no console.log(x)...this means that something is wrong in line <code>const x = builder.buildObject(data)</code> isn't it?</p>
  <pre><code>export const buildXML = (data: any[]) =&gt; {
    const builder = new xml2js.Builder();
    const x = builder.buildObject(data)
    console.log('x:', x)
    return x
  }
  </code></pre>