Table of contents
TOC
Collapse the table of content
Expand the table of content

CustomXMLNode.AppendChildNode Method (Office)

office 365 dev account|Last Updated: 6/12/2017
|
1 Contributor

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

NameRequired/OptionalData TypeDescription
NameOptionalStringRepresents the base name of the element to be appended.
NamespaceURIOptionalStringRepresents the namespace of the element to be appended. This parameter is required to append nodes of type msoCustomXMLNodeElement or msoCustomXMLNodeAttribute, otherwise it is ignored.
NodeTypeOptionalMsoCustomXMLNodeTypeSpecifies the type of node to append. If the parameter is not specified, it is assumed to be of type msoCustomXMLNodeElement.
NodeValueOptionalStringUsed 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

Other resources

CustomXMLNode Object Members

© 2018 Microsoft