February 4, 2002 - Creating New XML Tree Nodes
February 4, 2002 Creating New XML Tree Nodes Tips: February 2002
Yehuda Shiran, Ph.D.
|
createNode()
method. The syntax of the method is as follows:
createNode(type, name, namespaceURI)
where:
type
is a value that uniquely identifies the nodetype
. It can be specified by an integer between1
and12
, or by a string identical to thenodeTypeString
property of the node. For example, to create a node of typeattribute
, settype
to2
or"attribute"
.name
is a string containing the new node's desirednodeName
property. You cannot set the name of all node types. Some node types enforce a constant string as their node name. The day before yesterday we listed all node types and the restrictions on their names. For example, node type11
("documentfragment"
) has a fixed name ("#document-fragment"
) which you cannot change. Specify an empty string for such node types (""
). Non-empty strings will be ignored.namespaceURI
is a string defining the namespace Uniform Resource Identifier (URI). If specified, the node will be created in the context of thenamespaceURI
, including any prefix specified with the node name. If a prefix is not specified, the default namespace is used. WhennamespaceURI
is the empty string,""
, the node is created within the special namespace of the current document.