Sample code for 30+ languages & platforms
Tcl

Creating a New Child Node

See more XML Examples

Demonstrates how to create a new child in an XML document.

The following XML sample code produces this output:


<abc>
    <xyz>
        <mmm>123</mmm>
    </xyz>
</abc>

Chilkat Tcl Downloads

Tcl

load ./chilkat.dll

set xml [new_CkXml]

CkXml_put_Tag $xml "abc"

# Create a new child  with no content 
# and return the newly created child node:
# childNode is a CkXml

set childNode [CkXml_NewChild $xml "xyz" ""]

# Create a child under childNode, but instead call
# NewChild2 which doesn't return the newly created child node:
CkXml_NewChild2 $childNode "mmm" "123"

delete_CkXml $childNode

puts [CkXml_getXml $xml]

delete_CkXml $xml