Welcome to WebHeadStart.org

Web Technologies

Sponsored By

WebHeadStart.org is currently in beta.
Please pardon our appearance as we work to provide you with the most comprehensive reference on today's web technologies.

Interested in advertising on WebHeadStart? Become an advertising partner today!

[WWW-HTML Mailing List Archive Home] [Messages By Thread] [Messages By Date]

Document.parseHTML(txt) - Why not?

From: Marcus <marcus3v@hotmail.com>
Date: Mon, 8 Mar 2004 16:21:55 -0300
To: <www-html@w3c.org>, <www-dom@w3c.org>
Message-ID: <BAY7-DAV25oAfCQYBfn000324c4@hotmail.com>

I believe that the addition of an method similar to the innerHTML "DHTML"
property, that is implemented by some current browsers -- IE, Mozilla... --,
would be extremely useful, principally for script writers.
Such hypothetical method, the return of which would be a DocumentFrament
object, would look like this ( assume a ECMA262 enviroment ):

docFrag=doc.parseHTML(str)

where "doc" is a object variable that implements the Document Interface and
"str" is a string variable that contains HTML markup, for instance:

'<div id="el0">xxx <span id="el1" class="xx">xx<\/span><\/div>'

( obs.: the reverse method, docFragTxt=doc.parseStr(docFrag) would,
likewise, exist ).

In spite of the incontestable robustness of the DOM, a implacable
hierarchization of objects and methods may seem a bit maddening for a script
writer, since he would, relatively, spend a lot of work for the creation of
simple and trivial pieces of HTML. In order to create the above fragment --
that is extraordinarily short -- with the currently existent DOM interfaces,
5 Elements ( 1 DIV, 2 SPAN and 2 Text ) must be generated, 3 properties must
be applied and, finally, 4 nestings ( appendChild(), or
insert[After||Before]()... ) must be executed. This would be done with only
1 line of friendly code, if the "parse[HTML||Str]()" method existed...
Received on Monday, 8 March 2004 14:22:42 GMT
Valid XHTML 1.0! Valid CSS! Site Map | Privacy Policy | Terms of Use | WebHeadStart.org © 2005 All Rights Reserved.