Re: How can I create an Element Node

Smaug <[email protected]> Tue, 27 Apr 2010 01:53:45 +0300
Newsgroups gmane.comp.mozilla.devel.dom
Message-ID <[email protected]>
On 4/27/10 12:31 AM, andy lau wrote:
> Hi,
>
> Can you please tell me how can I create an Element Node for a
> nsDocument?
>
> http://mxr.mozilla.org/mozilla1.9.1/source/content/base/src/nsDocument.cpp#4621
>
> After I create an Element Node, I can add tagName, add attribute key
> and value to that?
>
> Thank you.

The easiest way is probably to QI nsIDocument object to nsIDOMDocument
and call its CreateElement or CreateElementNS method.
After that you can add the attributes you need to.

(I don't know why you added the link to that line
in nsDocument.)

Btw, any reason why you don't use anything newer than 1.9.1?


-Olli