Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Removes the specified node (and its subtree) from the main tree, and replaces it with a different subtree in the same location.
Syntax
expression.ReplaceChildSubtree(XML, OldNode)
expression An expression that returns a CustomXMLNode object.
Parameters
| Name | Required/Optional | Data type | Description |
|---|---|---|---|
| XML | Required | String | Represents the subtree to be added. |
| OldNode | Required | CustomXMLNode | Represents the child node to be replaced. |
Remarks
If the operation would result in an invalid tree structure, the replacement operation is not performed and an error message is displayed.
Example
The following example selects a custom part and then a node in that part. The code then replaces a child subtree of that node with another subtree.
Dim cxp1 As CustomXMLPart
Dim cxn As CustomXMLNode
With ActiveDocument
' Return the first custom xml part with the given root namespace.
Set cxp1 = .CustomXMLParts("urn:invoice:namespace") '
' Get node using XPath expression.
Set cxn = cxp1.SelectSingleNode("//*[@supplierID = 1]")
' Replace one subtree and its children with another.
cxn.ReplaceChildSubtree("<rebates><rebate>0.10</rebate></rebates>", "//discounts")
End With
See also
Support and feedback
Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.