<a download="hello.xml" href='#' id="link">Загрузить</a> <script> var text = "<OPTP5101>Them-on-us Sale POS</OPTP5101><OPTP5102>Them-on-us Refund POS </OPTP5102>"; let blob = new Blob([text], {type: 'text/plain'}); link.href = URL.createObjectURL(blob); </script>después de descargar el archivo y abrirlo, solo tengo lo siguiente
Them-on-us Sale POSNecesito todo el texto en el archivo xml después de descargarlo así.
<OPTP5101>Them-on-us Sale POS</OPTP5101> <OPTP5102>Them-on-us Refund POS </OPTP5102>¿Alguien sabe que me ayude por favor!
Encontré la solución cuando agregué al principio y al final del texto como este, todo se muestra cuando se abre con un navegador
begining var text="<xml_cfg><global_params><param><name>OPTP</name><value>"; end text = text + "</value></param></global_params></xml_cfg>"Y el código completo se parece a lo siguiente
<a download="hello.xml" href="#" id="link">download xml</a> <script language="JavaScript"> var text="<xml_cfg><global_params><param><name>OPTP</name><value>"; $.ajax({ url: "rep.svxp_xml_download.download_xml_for_svxp", type: "POST", dataType: "json", data:{}, error: function(XMLHttpRequest, textStatus, errorThrown) { toastr.error("Произошла ошибка "+textStatus,"Информация", {"closeButton": true}); return; }, success: function(data){ for(let i=0; i<data.length; i++){ text = text + "<" + data[i].optp + ">" + data[i].description + "</" + data[i].optp + ">"; } text = text + "</value></param></global_params></xml_cfg>" let blob = new Blob([text], {type: "text/plain"}); link.href = URL.createObjectURL(blob); } }); </script