CustomXMLNode.AppendChildNode Method (Office)

Appends a single node as the last child under the context element node in the tree.

Syntax

expression .AppendChildNode(Name, NamespaceURI, NodeType, NodeValue)

expression An expression that returns a CustomXMLNode object.

Parameters

Name

Required/Optional

Data Type

Description

Name

Optional

String

Represents the base name of the element to be appended.

NamespaceURI

Optional

String

Represents the namespace of the element to be appended. This parameter is required to append nodes of type msoCustomXMLNodeElement or msoCustomXMLNodeAttribute, otherwise it is ignored.

NodeType

Optional

MsoCustomXMLNodeType

Specifies the type of node to append. If the parameter is not specified, it is assumed to be of type msoCustomXMLNodeElement.

NodeValue

Optional

String

Used to set the value of the appended node for those nodes that allow text. If the node doesn’t allow text, the parameter is ignored.

Remarks

If the context node is any type other than msoXMLNodeElement, or if the operation would result in an invalid tree structure, the append is not performed and an error message is displayed.

Example

The following example demonstrates appending a CustomXMLNode object to another node.

Sub AppendNode() 
    Dim cxp1 As CustomXMLPart 
    Dim cxn As CustomXMLNode 
 
    With ActiveDocument 
 
        ' Add and populate a custom xml part 
        set cxp1 = .CustomXMLParts.Add "<invoice />" 
         
        ' Add a node 
        cxp1.AddNode "/invoice", "upccode", "urn:invoice:namespace" 
                        
        Set cxn = cxp1.SelectSingleNode("//*[@quantity < 4]")  
 
        ' Append a child node to the single node selected previously. 
        cxn.AppendChildNode("discount", "urn:invoice:namespace", "string", "0.10")          
                         
    End With 
     
End Sub

See Also

Concepts

CustomXMLNode Object

CustomXMLNode Object Members