javascript: parse HTML string into DOM

Discussion in 'Firefox' started by kit, Feb 4, 2008.

  1. kit

    kit

    Joined:
    Jan 27, 2008
    Messages:
    1
    Likes Received:
    0
    As title, I need to parse html string into node-tree.
    But there are some complications.
    1) I need to parse HTML, not XHTML or some other XML subsets. e.g. text may have 'script' tags with plain javascript inside.
    2) I need to parse whole HTML document. From <html xmlns=...> to </html>. Many methods (like innerHTML or some dojo functions) can't handle whole HTML document but only pieces. Moreover, when I write html document in that way, internal content usually becomes corrupted. Simply speaking, most of tags are missed in resulted structure.

    In fact, after few days of search I've come to solution which works for IE7. Will describe it briefly. 'iframe' tag by default has empty document inside (even if it's declared without 'src' attribute). So it's possible to declare hidden iframe and then make 'doc.write(text)'. But in FF written data becomes corrupted, like I said above.

    So the question: may be someone did something similiar before :) The problem is really weird and I gonna give up. Will appreciate any help.
     
    kit, Feb 4, 2008
    #1
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.