Class XMLNodes (Word VBA)

A collection of XMLNode objects that represents the nodes in the tree view of the XML Structure task pane, which indicates the elements that a user has applied to a document. Each node in the tree view is an instance of an XMLNode object. The hierarchy in the tree view indicates whether a node contains child nodes.Y

To use a XMLNodes class variable it first needs to be instantiated, for example

Dim xmls as XMLNodes
Set xmls = ActiveDocument.SelectSingleNode.Attributes

The following procedures can be used to set variables of type XMLNodes: Document.SelectNodes, XMLNode.Attributes, XMLNode.ChildNodes and XMLNode.SelectNodes.

Count

Returns a Long that represents the number of XML elements in the collection.

Dim lngCount As Long
lngCount = ActiveDocument.SelectSingleNode.Attributes.Count

Item

Returns an individual XMLNode object in a collection.

Item (Index)

Index: The individual object to be returned. Can be a Long indicating the ordinal position of the individual object.

Dim xml As XMLNode
Set xml = ActiveDocument.SelectSingleNode.Attributes(Index:=1)