Adds a node to the XML 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.AddNode(Parent, Name, NamespaceURI, NextSibling, NodeType, NodeValue)

expression An expression that returns a CustomXMLPart object.

Parameters

Name Required/Optional Data Type Description
Parent Required CustomXMLNode Represents the node under which this node should be added. If adding an attribute, the parameter denotes the element that the attribute should be added to.
Name Optional String Represents the base name of the node to be added.
NamespaceURI Optional String Represents the namespace of the element to be appended. This parameter is required to append nodes of type msoCustomXMLNodeElement or msoCustomXMLNodeAttribute, otherwise it is ignored.
NextSibling Optional CustomXMLNode Represents the node which should become the next sibling of the new node. If not specified, the node is added to the end of the parent node's children. This parameter is ignored for additions of type msoXMLNodeAttribute. If the node is not a child of the parent, an error is displayed.
NodeType Optional MsoCustomXMLNodeType Specifies the type of node to append. If the parameter is not specified, it is assumed to be of type msoCustomXMLNodeElement.
NodeValue Optional String Used 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 AddNode operation would result in an invalid tree structure, the append is not performed and an error message is displayed.

Example

The following example demonstrates adding a node to a CustomXMLPart object.

Visual Basic for Applications
Sub AddNodeCustomXmlParts() Dim cxp1 As CustomXMLPart With ActiveDocument ' Add and populate a custom xml part set cxp1 = .CustomXMLParts.Add "<invoice />" ' Add a node cxp1.AddNode "/invoice", "upccode", "urn:invoice:namespace" End With End Sub

See also: