I am programming a extension for chrome for my company. I am creating a XML file out of a API request. The XML file is used for an import, and the program that gets the import, doesn't like the charset=utf-8
at the beginning of the XML (see short XML below).
charset=utf-8
<xml>
xml data
</xml>
I have to manually remove the charset=utf-8
and it works.
Below you find the js code for the download. I do not add the charset=utf-8
manually. It must be in that code, but I don't find the problem.
var filename = prompt('Enter file name:', 'XML_file_export');
var downloadPath = prompt('Enter download path:', 'XML_export');
chrome.downloads.download({url:'data:text/xml,charset=utf-8' + encodeURIComponent(xmlData), filename: downloadPath + filename});
Please can someone help me to remove that charset=utf-8
at the beginning of the XML file. It is the first time that I work with this and I haven't found any information about that.
I've tried to remove that charset=utf-8
from the chrome.downloads.download
, but than it wasn't downloading. Also I have tried without the encodeURIComponent
but it also haven't worked.