W3C home > Mailing lists > Public > www-dom@w3.org > July to September 2009

Re: How can I create a HTMLDocument from the DOMImplementation

From: Bo Yang <struggleyb.nku@gmail.com>
Date: Wed, 19 Aug 2009 17:45:31 +0800
Message-ID: <41f08ee10908190245q3679b00ep4d404419e6c1c18f@mail.gmail.com>
To: Olli Pettay <Olli.Pettay@helsinki.fi>
Cc: www-dom@w3.org
On Tue, Aug 18, 2009 at 9:37 PM, Olli Pettay<Olli.Pettay@helsinki.fi> wrote:
> On 8/18/09 4:14 PM, Bo Yang wrote:
>>
>> Hi,
>>
>>     The Core module define the DOMImplementation interface which is
>> used to bootstrap the DOM, to create Document and DocumentType. But I
>> can't find a way to create a specific type of Document from that
>> interface. I mean, how can I create HTMLDocument from some
>> DOMImplementation? Thanks!
>>
>> Regards!
>> Bo
>>
>>
>
> In Gecko one can do it for example this way:
> var dt =
>  document.implementation.createDocumentType(
>    "html",
>    "-//W3C//DTD HTML 4.01//EN",
>    null);
> var doc = document.implementation.createDocument(null, null, dt);
>
> This behavior is based on DOM 3 Core
> "Note that based on the DocumentType  given to create the document, the
> implementation may instantiate specialized Document  objects that support
> additional features than the "Core", such as "HTML" [DOM Level 2 HTML]."
>
>
> IIRC, not all browser engines support creating specialized document
> objects based on document type.

Thanks, I think this is the standard way to create a HTMLDocument, :)

Regards!
Bo
Received on Wednesday, 19 August 2009 09:46:13 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Friday, 22 June 2012 06:14:03 GMT