S
S
Sergey questions2017-10-30 20:27:05
PHP
Sergey questions, 2017-10-30 20:27:05

Unload content of textarea in xml view, perhaps?

Hello uv. Connoisseurs-masters :) I ask for your help.
There is this code in the html page:

<form name="test">
  <textarea name="content">
    <item>
      <product>ムひオムムひクムミセミイミーミスミクミオ</product>
      <category>ミオム禍オ ムひオムム</category>
    </item>
    <item>
      <product>ムひオムムひクムミセミイミーミスミクミオ</product>
      <category>ミオム禍オ ムひオムム</category>
    </item>
    ミク ム.ミエ.....
  </textarea>
  <button type="submit" value="">ミ樮ひソムミーミイミクムび</button>
</form>


It is necessary after pressing the "Submit" button, the generated xml file with the contents of the textarea appeared for download.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Stalker_RED, 2017-10-30
@smartycms

let str = document.querySelector('form textarea[name="content"]').value
let xml = `<?xml version="1.0" ?><root>${str}<root></xml>` // ミエミセミアミーミイミサム紹オミシ ミキミーミウミセミサミセミイミセミコ ミク root

let blob = new Blob([xml], {type: "text/xml"}), // ムミセムミシミクムムσオミシ ムミーミケミサ
    url = window.URL.createObjectURL(blob);

let a = document.createElement("a");
a.style.display = 'none' // ムミコムム錦ひーム ムムム巾サミコミー
a.href = url
document.body.appendChild(a)
a.download = 'myXML.xml';
a.click()
window.URL.revokeObjectURL(url); // ムミーミケミサ ミシミセミカミスミセ ムσエミーミサミクムび
a.remove() // ムムム巾サミコム ムひセミカミオ

jsfiddle.net/Stalk/22swsnba Can
you write the handler for the button yourself?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question