Catch up on stories from the past week (and beyond) at the Slashdot story archive

 



Forgot your password?
typodupeerror
×
User Journal

Journal Quantum Jim's Journal: **Updated** Reading Files in Internet Explorer with JScript

My original article on Reading Files in Internet Explorer with JScript no longer seems to work with IE 6 SP 2. It seems that the behavior of node.nodeValue changed between revisions of Internet Explorer. Therefore use the following pattern instead:

function loadFile(url) {

var newFrame = document.createElement("xml");

newFrame.async = false;

return newFrame.load(url) ? getNodeString(newFrame) : "";

};

function getNodeString(node) {

return (node.nodeValue !== null) ? node.nodeValue : getChildrenString(node.childNodes);

};

function getChildrenString(children) {

var nodeString = "", numOfChildren = children.length;

for (var ii = 0; numOfChildren > ii; ii++) nodeString += getNodeString(children[ii]);

return nodeString;

};

That can be trivially turned back into a single function if you prefer. I think the new code is a little more elegant than the previous version. Here's a demo (that I may take down if I run out of online disk space). I haven't tested that with IE 6 SP 1, since I no longer have access to that version!

Oh, and I gladly dedicate this code to the public domain. It isn't as if I could copyright something that small and trivial anyway, IMHO.

P.S. Slash's support for souce code is still lacking....

This discussion has been archived. No new comments can be posted.

**Updated** Reading Files in Internet Explorer with JScript

Comments Filter:

Remember to say hello to your bank teller.

Working...