CustomXMLNode.InsertNodeBefore Method
Inserts a new node just before the context node in the tree.
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.InsertNodeBefore(Name, NamespaceURI, NodeType, NodeValue, NextSibling)
expression An expression that returns a CustomXMLNode object.
Parameters
| Name | Required/Optional | Data Type | Description |
|---|---|---|---|
| Name | Optional | String | Represents the base name of the node 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 the node to be added. If the parameter is not specified, it is assumed to be a node 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. |
| NextSibling | Optional | CustomXMLNode | Represents the context node. |
Remarks
If the context node is not present when adding a node of type msoCustomXMLNodeElement, msoCustomXMLNodeComment, or msoCustomXMLNodeProcessingInstruction, the new node is added to the last child of the context node. If the operation would result in an invalid tree structure, the insertion is not performed and an error message is displayed.
Example
The following example adds a custom part and then finds a node in that part by using an XPath expression. The code then inserts a node before the found node.
| Visual Basic for Applications |
|---|
|
Note