Re: Implementing Document.createElement, etc.

>If I have an empty Document object (where hasChildNodes() returns false)
>and I use createElement() to create a new Element object, does
>hasChildNodes() still return false?


hasChildNodes for both the element and the document will return false.

>If so, this would have an interesting implication: these newly created
>nodes can node be found by any of the methods used to traverse the
>document tree, like Node.getChildNodes() in the Java implementation. And
>a Document object that is used to create an Attribute object with
>Document.createAttribute() would not return that Attribute when
>Node.getAttributes() is called in the Java implementation.


Newly created nodes can not be found by any of the methods used to traverse
the document tree.  getAttributes() also will not return newly created Attr
object.

>My understanding is this: An Element node can be created using a Document
>and that Document would be the Element's ownerDocument (but not parent).
>Once an Element object is placed in the Document tree using a method like
>Node.appendNode(), then and only then would it appear as a child object
>of any other object.


Correct.

Don Park
Docuverse

Received on Thursday, 8 October 1998 11:19:44 UTC