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 노드 목록입니다.

예제

다음 코드 예제에서는 컨트롤에서 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 메서드를 XPathBinder.Select 사용하여 메서드를 GetDataItem 호출하여 식이 계산되는 개체 참조를 확인 IXPathNavigable 합니다.

추가 정보

적용 대상