CustomXMLNode.AppendChildSubtree Method (Office)

Adds a subtree as the last child under the context element node in the tree.

Syntax

expression .AppendChildSubtree(XML)

expression An expression that returns a CustomXMLNode object.

Parameters

Name

Required/Optional

Data Type

Description

XML

Required

String

Represents the subtree to add.

Remarks

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

Example

The following example demonstrates appending a node to an existing node.

Sub ShowCustomXmlParts() 
    Dim cxp1 As CustomXMLPart 
    Dim cxn As CustomXMLNode 
 
    With ActiveDocument 
 
        ' Add and populate a custom xml part 
        set cxp1 = .CustomXMLParts.Add "<invoice />" 
         
        ' Get nodes using XPath.                              
        Set cxn = cxp1.SelectSingleNode("//*[@quantity < 4]")  
  
        ' Append a child subtree to the single node selected previously. 
        cxn.AppendChildSubtree("<discounts><discount>0.10</discount></discounts>")          
         
    End With 
     
End Sub

See Also

Concepts

CustomXMLNode Object

CustomXMLNode Object Members