|
Posted by RobG on 01/05/65 11:44
David Virgil Hobbs wrote:
> Loading text strings containing HTML code into an HTML parser in a
> Javascript/Jscript
>
> I would like to know, how one would go about loading a text string
> containing HTML code, so as to be able to use javascript or Jscript to
> work with the HTML code in the text string, in the same way that one
> works with XML code in a text string using the XML parser.
A JavaScript function posted about a week ago (it lacks feature
detection and is only lightly tested):
function toDOM(HTMLstring)
{
var d = document.createElement('div');
d.innerHTML = HTMLstring;
var docFrag = document.createDocumentFragment();
while (d.firstChild) {
docFrag.appendChild(d.firstChild)
};
return docFrag;
}
<URL:http://groups.google.com/group/comp.lang.javascript/browse_frm/thread/d9855d899b8a6544/4c4071600634c1ad?q=HTML+to+DOM+Function&rnum=1#4c4071600634c1ad>
[...]
> Microsoft's xml parser, allows you to load a text string containing xml
> code, such as text in an html form input, and then use javascript to
> work with this text string containing xml code, as if you were working
> with an xml.
The W3C DOM 3 Load and Save includes interfaces for parsing and
serialising XML, however they aren't widely implemented yet.
<URL:http://www.w3.org/TR/DOM-Level-3-LS/load-save.html>
[...]
--
Rob
[Back to original message]
|