February 6, 2002 - Particular-Type Node Generation
February 6, 2002 Particular-Type Node Generation Tips: February 2002
Yehuda Shiran, Ph.D.
|
DOMDocument
object exposes both the generic createNode()
method as well as methods to create particular-type nodes, such as the createElement()
method. Creating an element with this method is the same as creating a node with createNode()
where the type is "element"
and no namespace is specified. In order to create a namespace-qualified attribute, use the createNode()
method. You can only set the name of the element with createElement()
. Set the text
property of the node to set the content of the element.
Notice that when you create the element
object, it is not automatically connected to the current document's tree. Its ownerDocument
property is equal to the document
object, but its parentNode
property is null
. Use one of the three inserting methods to hook the new element object to the document tree: insertBefore()
, replaceChild()
, or appendChild()
.