Share via


View.GetSelectedNodes Method

InfoPath Developer Reference

Returns a reference to an XMLNodes collection that is populated with XML Document Object Model (DOM) nodes based on the current selection of items in a view.

Version Information
 Version Added:  InfoPath 2003

Syntax

expression.GetSelectedNodes

expression   An expression that returns a View object.

Return Value
XMLNodes

Remarks

If no items are selected in a view, or if only text is selected, then the GetSelectedNodes method returns an empty collection.

Security Level 2: Can be accessed only by forms running in the same domain as the currently open form, or by forms that have been granted cross-domain permissions.

Example

In the following example, the GetSelectedNodes method of the View object is used to set a reference to a collection of XML DOM nodes based on what is currently selected in the view. Then the code determines whether nodes were returned and, if they were, displays information about the first node found in the XMLNodes collection in a message box.

JScript
  objXMLNodes = XDocument.View.GetSelectedNodes();
if (objXMLNodes.Count > 0)
{
   XDocument.UI.Alert(objXMLNodes(0).nodeName + "\n\n" + objXMLNodes(0).text);
}

See Also