TemplateControl.XPathSelect メソッド
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
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 ノード リスト。
注釈
XPathSelect メソッドは、GetDataItem メソッドを使用してXPathBinder.Select メソッドを呼び出して、式が評価される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 ノード リスト。
例
次のコード例では、Repeater コントロールで XPathSelect メソッドを使用する方法を示します。
<%@ 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 メソッドは、GetDataItem メソッドを使用してXPathBinder.Select メソッドを呼び出して、式が評価されるIXPathNavigable オブジェクト参照を解決します。