Created
November 10, 2012 06:46
-
-
Save pocari/4050215 to your computer and use it in GitHub Desktop.
html parse sample
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fso = new ActiveXObject("Scripting.FileSystemObject"); | |
function with_openfile(path, action) { | |
var f = null; | |
try { | |
f = fso.openTextFile(path); | |
return action(f); | |
} finally { | |
if (f) { | |
f.close(); | |
} | |
} | |
} | |
function get_domdocument_from_file(path) { | |
return with_openfile(path, function (f) { | |
return get_domdocument(f.readAll()) | |
}); | |
} | |
function get_domdocument(contents) { | |
var document = WScript.CreateObject("htmlfile"); | |
document.write(contents); | |
return document; | |
} | |
function main() { | |
var document = get_domdocument("<table><tr><td>1</td></tr></table>"); | |
var nodes = document.getElementsByTagName("td"); | |
var str = ""; | |
for (var i = 0; i < nodes.length; i++) { | |
str += nodes[i].innerText + "\n"; | |
} | |
WScript.Echo(str); | |
} | |
WScript.quit(main()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment