Given this solution on how to create XML format to my data (Convert JavaScript object (array) to XML)
I need now a way to make auto download this into a .xml file this is my code:
toXml = (data) => {
    return data.reduce((result, el) => {
        if (el.title && el.author)
            return result + `<BookData><title>${el.title}</title><author>${el.author}</author></BookData>\n`
        if (el.title && !el.author)
            return result + `<BookData><title>${el.title}</title></BookData>\n`
        if (!el.title && el.author)
            return result + `<BookData><author>${el.author}</author></BookData>\n`
    }, '')
}
if (type == 2)
{
    let data = this.toXml(arrayData);
    console.log(data);
}
Where I pass the data to create my XML?
What should I code instead of console.log(data); so I can get the downloaded .xml file?
Edit: Answered in How to create and download an XML file on the fly using javascript?
 
     
    