Project function

Local resolution

Upload a file

<input
    class="input"
    ref="file"
    type="file"
    @change="handleFileChange"
/>       

Parsing the File object

Get the file object, and get the local URL path address

Const getUploadUrl = function(flie) {let url = ""; if (window.createObjectURL ! = undefined) { // basic url = window.createObjectURL(flie); } else if (window.webkitURL ! = undefined) { // webkit or chrome url = window.webkitURL.createObjectURL(flie); } else if (window.URL ! = undefined) { // mozilla(firefox) url = window.URL.createObjectURL(flie); } return url; / / return such a string of address blob:http://www.xxxx.com/2c230fa5-ecc4-4314-ae7c-c39eaa66a945};

Parse the file to get the XML object

const loadXML = function(xmlFile) { var xmlDom = null; if (window.ActiveXObject) { xmlDom = new ActiveXObject("Microsoft.XMLDOM"); xmlDom.async = "false"; xmlDom.load(xmlFile); } else if ( document.implementation && document.implementation.createDocument ) { var xmlhttp = new window.XMLHttpRequest(); xmlhttp.open("GET", xmlFile, false); xmlhttp.send(null); xmlDom = xmlhttp.responseXML; } else { xmlDom = null; } return xmlDom; // Returns a doucument object};

Document object to string

let url = getUploadUrl(file); // file object let XML = loadXML(url); Let text = new XmlSerializer (). SerializeToString (XML) // Assign text to textarea var element = new XmlSerializer (). SerializeToString (XML document.getElementById('textarea'); element.value = text

Garbled code will appear

To solve the code

Open the file with Notepat ++, convert it to UTF-8, and save it as a new file