TemplateControl.XPathSelect Metodo
Definizione
Importante
Alcune informazioni sono relative alla release non definitiva del prodotto, che potrebbe subire modifiche significative prima della release definitiva. Microsoft non riconosce alcuna garanzia, espressa o implicita, in merito alle informazioni qui fornite.
Fornisce il data binding in fase di esecuzione sui dati basati su XML e restituisce una raccolta di nodi che implementa l'interfaccia IEnumerable .
Overload
| Nome | Descrizione |
|---|---|
| XPathSelect(String, IXmlNamespaceResolver) |
Valuta un'espressione di data binding XPath usando il prefisso e i mapping dello spazio dei nomi specificati per la risoluzione dello spazio dei nomi e restituisce una raccolta di nodi che implementa l'interfaccia IEnumerable . |
| XPathSelect(String) |
Valuta un'espressione di data binding XPath e restituisce una raccolta di nodi che implementa l'interfaccia IEnumerable . |
XPathSelect(String, IXmlNamespaceResolver)
Valuta un'espressione di data binding XPath usando il prefisso e i mapping dello spazio dei nomi specificati per la risoluzione dello spazio dei nomi e restituisce una raccolta di nodi che implementa l'interfaccia 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
Parametri
- xPathExpression
- String
Espressione XPath da valutare. Per altre informazioni, vedere XPathBinder.
- resolver
- IXmlNamespaceResolver
Set di mapping di prefissi e spazi dei nomi usati per la risoluzione dello spazio dei nomi.
Valori restituiti
Elenco di IEnumerable nodi.
Commenti
Il XPathSelect metodo chiama il metodo utilizzando il GetDataItemXPathBinder.Select metodo per risolvere il riferimento all'oggetto IXPathNavigable rispetto al quale viene valutata l'espressione.
Vedi anche
Si applica a
XPathSelect(String)
Valuta un'espressione di data binding XPath e restituisce una raccolta di nodi che implementa l'interfaccia 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
Parametri
- xPathExpression
- String
Espressione XPath da valutare. Per altre informazioni, vedere XPathBinder.
Valori restituiti
Elenco di IEnumerable nodi.
Esempio
Nell'esempio di codice seguente viene illustrato come utilizzare il XPathSelect metodo in un Repeater controllo .
<%@ 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>
Nell'esempio di codice precedente è possibile usare i dati XML di test seguenti.
<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>
Commenti
Il XPathSelect metodo chiama il metodo utilizzando il GetDataItemXPathBinder.Select metodo per risolvere il riferimento all'oggetto IXPathNavigable rispetto al quale viene valutata l'espressione.