How can I read a file line by line in javascript and display each line in a different HTML tag? For example I want to store each line of the file in the a different <li> tag.
This is what I've tried so far, but it just displays the entire file as a whole. I want each line in a different tag:
 <embed src="C://whatever.txt">
Also tried code below but puts everything on the same line and not in different <li> tags but just in one:
    window.onload = function() {
    var ul = document.getElementsByTagName('ul')[0];
    function readTextfile() {
        var xhr = new XMLHttpRequest();
        xhr.onreadystatechange = function() {
            if (xhr.readyState === 4) {
                if (xhr.status == 200) {
                    showContents(xhr.responseText, xhr);
                }
            }
        }
        xhr.open('GET', "C://whatever.txt", true);
        xhr.send();
    }
    function showContents(responseText) {
        var li = document.createElement('li');
        var date = new Date();
        li.innerHTML = date + ': ' + responseText;
        ul.appendChild(li);
    }
    readTextfile();
 
    