IWETHEY v. 0.3.0 | TODO
1,095 registered users | 0 active users | 0 LpH | Statistics
Login | Create New User
IWETHEY Banner

Welcome to IWETHEY!

New Better way to do this?
Javascript to create a node from text:

function createNodeFromText(text, nodeToReturn)\n{\n\tvar container = document.createElement("span");\n\tcontainer.innerHTML = text;\n\t\n\tif (!nodeToReturn)\n\t{\n\t\treturn container.firstChild;\n\t}\n\telse\n\t{\n\t\treturn  container.getElementsByTagName(nodeToReturn.toUpperCase()).item(0);\n\t}\n}


'nodeToReturn' allows you to select something from within the created DOM: createNodeFromText("<table><tr><td>1</td><td>2</td></tr></table>", "tr") would return the TR node from the created node. Mainly I have to do this because you can't create just a TR with innerHTML.

Are there any better ways to create DOM from arbitrary text?
Regards,

-scott anderson

"Welcome to Rivendell, Mr. Anderson..."
New Short of building your own parser...
...no better way comes to mind (assuming the text is truly arbitrary).
New That looks pretty clean.
Although I understand you've objecting the the algorithm.

Have you looked on www.quirksmode.org? It can be hard to find things sometimes, but has code and discussions about that sort of thing.

Wade.
"Insert crowbar. Apply force."
     Better way to do this? - (admin) - (2)
         Short of building your own parser... - (ChrisR)
         That looks pretty clean. - (static)

An eye is upon you... staring straight down and keenly through!
127 ms