Javascript, FileReader vs XMLHttpRequest for reading a local file?
<p>I'm trying to read a local file with javascript and a Google Chrome App (it may not be possible through Chrome I think), but I can't see what's the latest approach to the problem.</p>

<p>I can read it with the following code:</p>

<pre><code>obj.read = function() {
    return new Promise(function(resolve){
        var xmlhttp = new XMLHttpRequest();
        var file_path = 'file_name.xml';
        xmlhttp.open('GET', file_path, true);
        xmlhttp.send(null);
        xmlhttp.onreadystatechange = function() {
            if (xmlhttp.readyState == 4 &amp;&amp; xmlhttp.status == 200) {
                let xml = xmlhttp.responseText;
                var parser = new DOMParser();
                var xmlDoc = parser.parseFromString(xml, "text/xml");
                console.log(xml);
                console.log(xmlDoc);
                resolve(xmlDoc);
            }
        }
    });
};
</code></pre>

<p>But it is like I should be using something like</p>

<pre><code>var reader = new FileReader();
reader.onload = (function(theFile) {
    return function(e) {
        console.log(e.target.result);
    };
})(file_path);

var file_path = 'file_name.xml';
var file_parts = [
    new Blob(['you construct a file...'],{type: 'text/plain'}), 
    'Same way as you do with blob',
    new Uint16Array([33])
];
var file = new File(file_parts, file_path);
reader.readAsText(file);
</code></pre>

<p>(copied from <a href="https://stackoverflow.com/a/24495213/826815">https://stackoverflow.com/a/24495213/826815</a>)
(I'm having a hard time finding literature on this topic)</p>

<p>So, what's the way to do it?</p>