This documentation is archived and is not being maintained.

TemplateControl.XPathSelect Method (String)

Evaluates an XPath data-binding expression and returns a node collection that implements the IEnumerable interface.

Namespace: System.Web.UI
Assembly: System.Web (in system.web.dll)

Protected Friend Function XPathSelect ( _
	xPathExpression As String _
) As IEnumerable
Dim xPathExpression As String
Dim returnValue As IEnumerable

returnValue = Me.XPathSelect(xPathExpression)
protected IEnumerable XPathSelect (
	String xPathExpression
protected internal function XPathSelect (
	xPathExpression : String
) : IEnumerable
Not applicable.



The XPath expression to evaluate. For more information, see XPathBinder.

Return Value

An IEnumerable node list.

The XPathSelect method calls the XPathBinder.Select method using the GetDataItem method to resolve the IXPathNavigable object reference that the expression is evaluated against.

The following code example demonstrates how to use the XPathSelect method in a Repeater control.

<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">

<html xmlns="" >
<head id="Head1" runat="server">
    <title>TemplateControl XPath Example</title>
    <h3>TemplateControl XPath and XPathSelect Example</h3>
    <form id="form1" runat="server">
        DataFile="contacts.xml" />    
          <hr />
            DataSource='<%# XPathSelect("contact") %>' >
              Name: <%# XPath("name") %> <br />
              Note: <%# XPath("note") %> <br />
              <hr />

The following test XML data can be used in the preceding code example.

   <contact id="1">
     <name>contact name 1</name>
     <note>contact note 1</note>
   <contact id="2">
     <name>contact name 2</name>
     <note>contact note 2</note>

Windows 98, Windows Server 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0