CustomXMLNode.ReplaceChildNode Method
Removes the specified child node (and its subtree) from the main tree, and replaces it with a different node in the same location.
Note
|
|---|
| References to DTDs from custom XML parts are not supported. DTD references in custom XML parts will not resolve, and custom XML parts containing DTD references generate an exception when an attempt is made to save the file's content to a flat XML file. |
Syntax
expression.ReplaceChildNode(OldNode, Name, NamespaceURI, NodeType, NodeValue)
expression An expression that returns a CustomXMLNode object.
Parameters
| Name | Required/Optional | Data Type | Description |
|---|---|---|---|
| OldNode | Required | CustomXMLNode | Represents the child node to be replaced. |
| Name | Optional | String | Represents the base name of the element to be added. |
| NamespaceURI | Optional | String | Represents the namespace of the element to be added. This parameter is required if adding nodes of type msoCustomXMLNodeElement or msoCustomXMLNodeAttribute, otherwise it is ignored. |
| NodeType | Optional | MsoCustomXMLNodeType | Specifies the type of node to add. If the parameter is not specified, it is assumed to be of type msoCustomXMLNodeElement. |
| NodeValue | Optional | String | Used to set the value of the node to be added for those nodes that allow text. If the node doesn't allow text, the parameter is ignored. |
Remarks
If theparameter is not a child of the context node or if the operation would result in an invalid tree structure, the replacement is not performed and an error message is displayed. In addition, in a case where the node to be added already exists, the replacement 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 of that node with another node.
| Visual Basic for Applications |
|---|
|
See also:
| OldNode |
Note