PDA

View Full Version : Parsing untagged text columns...


jrobexe
07-06-2007, 11:55 PM
I have imported a text file into an HTML DIV. The text appears within <pre></pre> tags and is non-tagged columns of numbers. I need to place these columns into a table or some format where I can transform them and operate on them mathematically. How do I parse the columns into a structure (a table, maybe)?

Arbitrator
07-07-2007, 08:58 PM
I have imported a text file into an HTML DIV. The text appears within <pre></pre> tags and is non-tagged columns of numbers. I need to place these columns into a table or some format where I can transform them and operate on them mathematically. How do I parse the columns into a structure (a table, maybe)?Try using PHP or XSLT.

rnd me
07-19-2007, 06:58 AM
this should get you started....
you might need to adjust the RegExps for your particular data.


function tags(tid) {
return document.getElementsByTagName(tid);
}

var bigRay=tags("pre")[0].innerHTML.split("\n")
for(z=0;z<bigRay.length; z++){
bigRay[z]=bigRay[z].split(/[\W]+/g)
}//next

alert( bigRay.join("\n") )