We recommend using Visual Studio 2017

View.SelectNodes Method (XPathNavigator, XPathNavigator) (Microsoft.Office.InfoPath)

Selects a range of nodes in a view based on the specified starting XML node and ending XML node.

Namespace: Microsoft.Office.InfoPath
Assembly: Microsoft.Office.InfoPath (in microsoft.office.infopath.dll)

public abstract void SelectNodes (
	XPathNavigator startNode,
	XPathNavigator endNode
)

Parameters

startNode

An XPathNavigator object that specifies the start node for the selection.

endNode

An XPathNavigator object that specifies the end node for the selection.

Exception typeCondition

InvalidOperationException

The SelectNodes method was called from an event handler for the Loading event.

ArgumentNullException

The parameters passed to this method are null.

ArgumentException

The parameters passed to this method arenot valid. For example, they are of the wrong type or format.

If the specified range of nodes is bound to more than one control in the view, you must use the SelectNodes(XPathNavigator,XPathNavigator,String) method. This allows you to specify the ViewContext identifier of the control that is bound to the range of nodes you want to select.

NoteNote:

The SelectNodes method requires that the specified nodes be structurally selectable in the view.

This member 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.

This type or member can be accessed only from code running in forms opened in Microsoft Office InfoPath 2007.

In the following example, the SelectNodes(startNode,endNode) method is used to select the range of nodes starting from the first row to the third row in a Repeating Table control bound to group2.

// Create XPathNavigators to specify range of nodes.
XPathNavigator repeatingTableRow1 = 
   CreateNavigator().SelectSingleNode(
   "/my:myFields/my:group1/my:group2[1]", NamespaceManager);
XPathNavigator repeatingTableRow3 = 
   CreateNavigator().SelectSingleNode(
   "/my:myFields/my:group1/my:group2[3]", NamespaceManager);

// Select range of nodes in specified XPathNavigators.
CurrentView.SelectNodes(repeatingTableRow1, repeatingTableRow3);
Show: