Forum Moderators: open
What you want is a server-side language, like Perl or PHP. That code gets executed by the server, not by your web browser.
A quick Google search [google.com] reveals some of the possibilities, but also the many limitations.
In general, it is best if file reading is handled on the server. JavaScript cannot be used to read local files on the computer.
Granted, this might be done better on the server, if that is possible, but gilbeccu hasn't said that he wants to read files locally. Reading text files (on your own domain) from a web page with JS is possible, and can be relatively easy. Reading local files is also possible with JS (as JScript) if you are running it as an HTA.
Equally, gilbeccu hasn't said that he wants to save this XML document as a file (yet). So "no" is a little premature there too.
We need those requirements filled out a bit, along with things like the format of the text file, and what information it contains
------ Easiest text file reading for IE (within domain) ---------
Include this element:
<IE:Download id = "mydata" style = "behavior:url(#default#download)" />
Use this script:
window.onload = function()
{
document.getElementById("mydata").startDownload("textfile.txt",handleData)
}
function handleData(text)
{
alert(text)
}