TemplateControl.XPathSelect メソッド

定義

XML ベースのデータに対してランタイム データ バインディングを提供し、IEnumerable インターフェイスを実装するノード コレクションを返します。

オーバーロード

XPathSelect(String, IXmlNamespaceResolver)

名前空間を解決するための指定されたプリフィックスと名前空間割り当てを使用して、XPath データ バインディング式を評価し、IEnumerable インターフェイスを実装するノード コレクションを返します。

XPathSelect(String)

XPath データ バインディング式を評価し、IEnumerable インターフェイスを実装するノード コレクションを返します。

XPathSelect(String, IXmlNamespaceResolver)

名前空間を解決するための指定されたプリフィックスと名前空間割り当てを使用して、XPath データ バインディング式を評価し、IEnumerable インターフェイスを実装するノード コレクションを返します。

protected public:
 System::Collections::IEnumerable ^ XPathSelect(System::String ^ xPathExpression, System::Xml::IXmlNamespaceResolver ^ resolver);
protected internal System.Collections.IEnumerable XPathSelect (string xPathExpression, System.Xml.IXmlNamespaceResolver resolver);
member this.XPathSelect : string * System.Xml.IXmlNamespaceResolver -> System.Collections.IEnumerable
Protected Friend Function XPathSelect (xPathExpression As String, resolver As IXmlNamespaceResolver) As IEnumerable

パラメーター

xPathExpression
String

評価する XPath 式です。 詳細については、「XPathBinder」を参照してください。

resolver
IXmlNamespaceResolver

名前空間を解決するために使用されるプリフィックスと名前空間割り当てのセット。

戻り値

IEnumerable

IEnumerable ノード リスト。

注釈

メソッドは XPathSelect 、メソッドを XPathBinder.Select 使用してメソッドを GetDataItem 呼び出して、式が IXPathNavigable 評価されるオブジェクト参照を解決します。

こちらもご覧ください

適用対象

XPathSelect(String)

XPath データ バインディング式を評価し、IEnumerable インターフェイスを実装するノード コレクションを返します。

protected public:
 System::Collections::IEnumerable ^ XPathSelect(System::String ^ xPathExpression);
protected internal System.Collections.IEnumerable XPathSelect (string xPathExpression);
member this.XPathSelect : string -> System.Collections.IEnumerable
Protected Friend Function XPathSelect (xPathExpression As String) As IEnumerable

パラメーター

xPathExpression
String

評価する XPath 式です。 詳細については、「XPathBinder」を参照してください。

戻り値

IEnumerable

IEnumerable ノード リスト。

次のコード例は、コントロールでメソッドを使用する XPathSelect 方法を Repeater 示しています。

<%@ Page Language="C#"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>TemplateControl XPath and XPathSelect Example</title>
</head>
<body>
    <h3>TemplateControl XPath Example</h3>
    <form id="form1" runat="server">
    <div>
      <asp:XmlDataSource
        id="XmlDataSource1" 
        runat="server"
        XPath="contacts" 
        DataFile="contacts.xml" />    
      <asp:FormView 
        id="FormView1" 
        runat="server" 
        DataSourceID="XmlDataSource1">
        <ItemTemplate>
          <hr />
          <asp:Repeater 
            id="Repeater1" 
            runat="server" 
            DataSource='<%# XPathSelect("contact") %>' >
            <ItemTemplate>
              Name: <%# XPath("name") %> <br />
              Note: <%# XPath("note") %> <br />
              <hr />
            </ItemTemplate>
          </asp:Repeater>
        </ItemTemplate>
      </asp:FormView>
    </div>
    </form>
</body>
</html>
<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title>TemplateControl XPath Example</title>
</head>
<body>
    <h3>TemplateControl XPath and XPathSelect Example</h3>
    <form id="form1" runat="server">
    <div>
      <asp:XmlDataSource
        id="XmlDataSource1" 
        runat="server"
        XPath="contacts" 
        DataFile="contacts.xml" />    
      <asp:FormView 
        id="FormView1" 
        runat="server" 
        DataSourceID="XmlDataSource1">
        <ItemTemplate>
          <hr />
          <asp:Repeater 
            id="Repeater1" 
            runat="server" 
            DataSource='<%# XPathSelect("contact") %>' >
            <ItemTemplate>
              Name: <%# XPath("name") %> <br />
              Note: <%# XPath("note") %> <br />
              <hr />
            </ItemTemplate>
          </asp:Repeater>
        </ItemTemplate>
      </asp:FormView>
    </div>
    </form>
</body>
</html>

前のコード例では、次のテスト XML データを使用できます。

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

注釈

メソッドは XPathSelect 、メソッドを XPathBinder.Select 使用してメソッドを GetDataItem 呼び出して、式が IXPathNavigable 評価されるオブジェクト参照を解決します。

こちらもご覧ください

適用対象