Xml.DocumentSource 속성
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
Xml 컨트롤에 표시할 XML 문서의 경로를 가져오거나 설정합니다.
public:
property System::String ^ DocumentSource { System::String ^ get(); void set(System::String ^ value); };
[System.ComponentModel.Bindable(true)]
public string DocumentSource { get; set; }
public string DocumentSource { get; set; }
[<System.ComponentModel.Bindable(true)>]
member this.DocumentSource : string with get, set
member this.DocumentSource : string with get, set
Public Property DocumentSource As String
속성 값
Xml 컨트롤에 표시할 XML 문서의 경로입니다.
- 특성
예제
다음 코드 예제에서는 컨트롤에서 XSL 변환을 사용 하 여 XML 문서를 표시 하는 Xml 방법을 보여 줍니다.
<!--
This sample shows an Xml control using the
DocumentSource and TransformSource properties to display Xml data
in the control.
Create a sample XML file called People.xml and
a sample XSL Transform file called Peopletable.xsl
using the code at the end of this sample.
-->
<%@ Page Language="C#" AutoEventWireup="True" %>
<%@ Import Namespace="System.Xml" %>
<%@ Import Namespace="System.Xml.Xsl" %>
<!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>Xml Class Example</title>
</head>
<body>
<h3>Xml Example</h3>
<form id="form1" runat="server">
<asp:Xml id="xml1" runat="server" DocumentSource="~/people.xml"
TransformSource="~/peopletable.xsl" />
</form>
</body>
</html>
<!--
For this example to work, paste the following code into a file
named peopletable.xsl. Store the file in the same directory as
your .aspx file.
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/People">
<xsl:apply-templates select="Person" />
</xsl:template>
<xsl:template match="Person">
<table width="80%" border="1">
<tr>
<td>
<b>
<xsl:value-of select="Name/FirstName" />
<xsl:value-of select="Name/LastName" />
</b>
</td>
</tr>
<tr>
<td>
<xsl:value-of select="Address/Street" /><br />
<xsl:value-of select="Address/City" />
,
<xsl:value-of select="Address/State" />
<xsl:value-of select="Address/Zip" />
</td>
</tr>
<tr>
<td>
Job Title: <xsl:value-of select="Job/Title" /><br />
Description: <xsl:value-of select="Job/Description" />
</td>
</tr>
</table>
</xsl:template>
<xsl:template match="bookstore">
<bookstore>
<xsl:apply-templates select="book"/>
</bookstore>
</xsl:template>
<xsl:template match="book">
<book>
<xsl:attribute name="ISBN">
<xsl:value-of select="@ISBN"/>
</xsl:attribute>
<price>
<xsl:value-of select="price"/>
</price>
<xsl:text>
</xsl:text>
</book>
</xsl:template>
</xsl:stylesheet>
-->
<!--
For this example to work, paste the following code into a file
named people.xml. Store the file in the same directory as
your .aspx file.
<?xml version="1.0" encoding="utf-8" ?>
<People>
<Person>
<Name>
<FirstName>Joe</FirstName>
<LastName>Suits</LastName>
</Name>
<address>
<Street>1800 Success Way</Street>
<City>Redmond</City>
<State>WA</State>
<ZipCode>98052</ZipCode>
</address>
<Job>
<title>CEO</title>
<Description>Runs the company</Description>
</Job>
</Person>
<Person>
<Name>
<FirstName>Linda</FirstName>
<LastName>Sue</LastName>
</Name>
<address>
<Street>1302 American St.</Street>
<City>Paso Robles</City>
<State>CA</State>
<ZipCode>93447</ZipCode>
</address>
<Job>
<title>Attorney</title>
<Description>Litigates trials</Description>
</Job>
</Person>
<Person>
<Name>
<FirstName>Jeremy</FirstName>
<LastName>Boards</LastName>
</Name>
<address>
<Street>34 Palm Avenue</Street>
<City>Waikiki</City>
<State>HI</State>
<ZipCode>98052</ZipCode>
</address>
<Job>
<title>Pro Surfer</title>
<Description>Rides waves</Description>
</Job>
</Person>
<Person>
<Name>
<FirstName>Joan</FirstName>
<LastName>Page</LastName>
</Name>
<address>
<Street>700 Webmaster Road</Street>
<City>Redmond</City>
<State>WA</State>
<ZipCode>98073</ZipCode>
</address>
<Job>
<title>Web Site Developer</title>
<Description>Writes ASP.NET pages</Description>
</Job>
</Person>
</People>
-->
<!--
This sample shows an Xml control using the
DocumentSource and TransformSource properties to display Xml data
in the control.
Create a sample XML file called People.xml and
a sample XSL Transform file called Peopletable.xsl
using the code at the end of this sample.
-->
<%@ Page Language="VB" AutoEventWireup="True" %>
<%@ Import Namespace="System.Xml" %>
<%@ Import Namespace="System.Xml.Xsl" %>
<!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>Xml Class Example</title>
</head>
<body>
<h3>Xml Example</h3>
<form id="form1" runat="server">
<asp:Xml id="xml1" runat="server" DocumentSource="~/people.xml"
TransformSource="~/peopletable.xsl" />
</form>
</body>
</html>
<!--
For this example to work, paste the following code into a file
named peopletable.xsl. Store the file in the same directory as
your .aspx file.
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/People">
<xsl:apply-templates select="Person" />
</xsl:template>
<xsl:template match="Person">
<table width="80%" border="1">
<tr>
<td>
<b>
<xsl:value-of select="Name/FirstName" />
<xsl:value-of select="Name/LastName" />
</b>
</td>
</tr>
<tr>
<td>
<xsl:value-of select="Address/Street" /><br />
<xsl:value-of select="Address/City" />
,
<xsl:value-of select="Address/State" />
<xsl:value-of select="Address/Zip" />
</td>
</tr>
<tr>
<td>
Job Title: <xsl:value-of select="Job/Title" /><br />
Description: <xsl:value-of select="Job/Description" />
</td>
</tr>
</table>
</xsl:template>
<xsl:template match="bookstore">
<bookstore>
<xsl:apply-templates select="book"/>
</bookstore>
</xsl:template>
<xsl:template match="book">
<book>
<xsl:attribute name="ISBN">
<xsl:value-of select="@ISBN"/>
</xsl:attribute>
<price>
<xsl:value-of select="price"/>
</price>
<xsl:text>
</xsl:text>
</book>
</xsl:template>
</xsl:stylesheet>
-->
<!--
For this example to work, paste the following code into a file
named people.xml. Store the file in the same directory as
your .aspx file.
<?xml version="1.0" encoding="utf-8" ?>
<People>
<Person>
<Name>
<FirstName>Joe</FirstName>
<LastName>Suits</LastName>
</Name>
<address>
<Street>1800 Success Way</Street>
<City>Redmond</City>
<State>WA</State>
<ZipCode>98052</ZipCode>
</address>
<Job>
<title>CEO</title>
<Description>Runs the company</Description>
</Job>
</Person>
<Person>
<Name>
<FirstName>Linda</FirstName>
<LastName>Sue</LastName>
</Name>
<address>
<Street>1302 American St.</Street>
<City>Paso Robles</City>
<State>CA</State>
<ZipCode>93447</ZipCode>
</address>
<Job>
<title>Attorney</title>
<Description>Litigates trials</Description>
</Job>
</Person>
<Person>
<Name>
<FirstName>Jeremy</FirstName>
<LastName>Boards</LastName>
</Name>
<address>
<Street>34 Palm Avenue</Street>
<City>Waikiki</City>
<State>HI</State>
<ZipCode>98052</ZipCode>
</address>
<Job>
<title>Pro Surfer</title>
<Description>Rides waves</Description>
</Job>
</Person>
<Person>
<Name>
<FirstName>Joan</FirstName>
<LastName>Page</LastName>
</Name>
<address>
<Street>700 Webmaster Road</Street>
<City>Redmond</City>
<State>WA</State>
<ZipCode>98073</ZipCode>
</address>
<Job>
<title>Web Site Developer</title>
<Description>Writes ASP.NET pages</Description>
</Job>
</Person>
</People>
-->
설명
컨트롤에 Xml 표시할 XML 문서는 세 가지 방법 중 하나로 지정됩니다. 적절한 속성을 설정하여 개체, XML 문자열 또는 XML 파일을 지정할 System.Xml.XmlDocument 수 있습니다. 이 DocumentSource 속성은 컨트롤에 표시할 XML 파일(XML 문서 표시)의 경로를 지정하는 데 사용됩니다. 상대 경로 또는 절대 경로를 사용할 수 있습니다. 상대 경로는 서버에서 전체 경로를 지정하지 않고 파일의 위치를 Web Forms 페이지 또는 사용자 컨트롤의 위치와 연결합니다. 경로 웹 페이지의 위치에 상대적입니다. 이렇게 하면 코드에서 파일 경로를 업데이트하지 않고도 서버의 다른 디렉터리로 전체 사이트를 더 쉽게 이동할 수 있습니다. 절대 경로는 전체 경로를 제공하므로 사이트를 다른 디렉터리로 이동하려면 코드를 업데이트해야 합니다.