Item Property (XMLNodes Collection)

Microsoft Office InfoPath

A read-only property that returns a reference to the specified XML Document Object Model (DOM) node from the XMLNodes collection.

expression.Item(ByVal varIndex As Variant) As IXMLDOMNode

expression    Required. Returns a reference to the XMLNodes collection.

varIndex Required Variant. A numeric expression that specifies the position of a member of the XMLNodes collection. The argument must be a number from 0 to the value of the collection's count property minus 1.

returns    A reference to an XML DOM node object.

Security Level

0: Can be accessed without restrictions.

Remarks

If the value provided for the varIndex argument does not match any existing member of the collection, an error occurs.

After you have set a reference to the XML DOM node object that the Item property returns, you can access any of its properties and methods.

Note  To learn more about the XML DOM and all of the properties and methods that it supports, see the MSXML 5.0 SDK documentation in the Microsoft Script Editor (MSE) Help system.

Example

In the following example, the Item property of the XMLNodes collection is used to return a reference to an XML DOM node object:

var objXMLNodes;
var objXMLNode;

objXMLNodes = XDocument.View.GetContextNodes();
objXMLNode = objXMLNodes.Item(0);

Because the Item property is the default property of the XMLNodes collection, it can also be used as follows:

var objXMLNodes;
var objXMLNode;

objXMLNodes = XDocument.View.GetContextNodes();
objXMLNode = objXMLNodes(0);