XMLNodes.Add Method (Word)

Returns an XMLNode object that represents a newly added element.

Syntax

expression .Add(Name, Namespace, Range)

expression Required. A variable that represents a XMLNodes collection.

Parameters

Name

Required/Optional

Data Type

Description

Name

Required

String

The name of the element in the XML schema designated in the Namespace parameter. Because XML is case-sensitive, the spelling of the element specified in the Name parameter must be exactly as it appears in the schema. If the does not match any of the element names in the schema specified in the Namespace parameter, an error is displayed.

Namespace

Required

String

The name of the schema as defined in the schema. The Namespace parameter is case-sensitive and must be spelled exactly as it appears in the schema. If the specified namespace cannot be found in any of the schemas attached to the document, an error is displayed.

Range

Optional

Range

The range to which you want to apply the element. The default is to place the element tags at the insertion point or around the selection if a text is selected.

Return Value

XMLNode

Example

The following example adds to the selected text the example element from the first schema referenced in the active document.

Sub AddNode() 
 ActiveDocument.XMLNodes.Add "example", _ 
 ActiveDocument.XMLSchemaReferences(1).NamespaceURI, _ 
 Selection.Range 
End Sub

See Also

Concepts

XMLNodes Collection

XMLNodes Object Members