XmlDocumentSchema 클래스

정의

XmlDocument의 구조 또는 스키마를 나타냅니다. 이 클래스는 상속될 수 없습니다.

public ref class XmlDocumentSchema sealed : System::Web::UI::Design::IDataSourceSchema
public sealed class XmlDocumentSchema : System.Web.UI.Design.IDataSourceSchema
type XmlDocumentSchema = class
    interface IDataSourceSchema
Public NotInheritable Class XmlDocumentSchema
Implements IDataSourceSchema
상속
XmlDocumentSchema
구현

예제

다음 코드 예제에서는 개체를 XmlDocumentSchema 사용하여 컨트롤에 XML 문서의 TreeView 구조를 표시합니다.

// This method fills a TreeView Web control from an XML file.
public void FillTreeView(TreeView treeVw, string fileName)
{
    // Get a reference to the current HttpContext
    HttpContext currentContext = HttpContext.Current;
    int i, j, k;
    TreeNode CurNode, NewNode;

    // Create and load an XML document
    XmlDocument XDoc = new XmlDocument();
    XDoc.Load(currentContext.Server.MapPath(fileName));

    // Get a map of the XML Document
    XmlDocumentSchema xSchema = new XmlDocumentSchema(XDoc, "");

    // Get a list of the root child views
    IDataSourceViewSchema[] RootViews = xSchema.GetViews();

    // Add each child to the TreeView
    for (i = 0; i < RootViews.Length; i++)
    {
        NewNode = new TreeNode(RootViews[i].Name);
        treeVw.Nodes.Add(NewNode);
        CurNode = treeVw.Nodes[i];

        // Get a list of children of this child
        IDataSourceViewSchema[] ChildViews = RootViews[i].GetChildren();
        // Add each child to the child node of the TreeView
        for (j = 0; j < ChildViews.Length; j++)
        {
            NewNode = new TreeNode(ChildViews[j].Name);
            CurNode.ChildNodes.Add(NewNode);
            CurNode = CurNode.ChildNodes[j];

            // Get a list of children of this child
            IDataSourceViewSchema[] ChildVws = ChildViews[j].GetChildren();
            // Add each child to the child node
            for (k = 0; k < ChildVws.Length; k++)
            {
                NewNode = new TreeNode(ChildVws[k].Name);
                CurNode.ChildNodes.Add(NewNode);
            }
            // Select the parent of the current child
            CurNode = CurNode.Parent;
        }
        // Select the parent of the current child
        CurNode = CurNode.Parent;
    }
}
Imports System.Xml
Imports System.Web
Imports System.Web.UI.WebControls
Imports System.Web.UI.Design

Public Class XmlDocumentSchemaSample

    ' This method fills a TreeView Web control from an XML file.
    Public Sub FillTreeView(ByVal treeVw As TreeView, ByVal fileName As String)
        ' Get a reference to the current HttpContext
        Dim currentContext As HttpContext = HttpContext.Current
        Dim i, j, k As Integer
        Dim CurNode, NewNode As TreeNode

        ' Create and load an XML document
        Dim XDoc As New XmlDocument()
        XDoc.Load(currentContext.Server.MapPath(fileName))

        ' Get a map of the XML Document
        Dim xSchema As New XmlDocumentSchema(XDoc, "")

        ' Get a list of the root child views
        Dim RootViews As IDataSourceViewSchema() = xSchema.GetViews()

        ' Add each child to the TreeView
        For i = 0 To RootViews.Length - 1
            NewNode = New TreeNode(RootViews(i).Name)
            treeVw.Nodes.Add(NewNode)
            CurNode = treeVw.Nodes(i)

            ' Get a list of children of this child
            Dim ChildViews As IDataSourceViewSchema() = RootViews(i).GetChildren()

            ' Add each child to the child node of the TreeView
            For j = 0 To ChildViews.Length - 1
                NewNode = New TreeNode(ChildViews(j).Name)
                CurNode.ChildNodes.Add(NewNode)
                CurNode = CurNode.ChildNodes(j)

                ' Get a list of children of this child
                Dim ChildVws As IDataSourceViewSchema() = ChildViews(j).GetChildren()
                ' Add each child to the child node
                For k = 0 To ChildVws.Length - 1
                    NewNode = New TreeNode(ChildVws(k).Name)
                    CurNode.ChildNodes.Add(NewNode)
                Next
                ' Select the parent of the current child
                CurNode = CurNode.Parent
            Next
            ' Select the parent of the current child
            CurNode = CurNode.Parent
        Next
    End Sub
End Class

설명

XmlDocumentSchema 클래스는 사용자 지정 컨트롤 디자이너 구성 요소에서 디자인 타임에 XML 문서의 구조적 요소를 나열하는 데 사용됩니다. XmlDocumentSchema 클래스를 사용하여 사용자가 디자인 타임에 UI 기능에서 문서 요소를 선택할 수 있도록 문서 요소 목록을 채웁니다.

생성자

XmlDocumentSchema(XmlDocument, String)

지정된 XmlDocumentSchema 및 XPath 문자열을 사용하여 XmlDocument 클래스의 인스턴스를 만듭니다.

메서드

Equals(Object)

지정된 개체가 현재 개체와 같은지 확인합니다.

(다음에서 상속됨 Object)
GetHashCode()

기본 해시 함수로 작동합니다.

(다음에서 상속됨 Object)
GetType()

현재 인스턴스의 Type을 가져옵니다.

(다음에서 상속됨 Object)
GetViews()

생성자의 xPath 매개 변수에 의해 식별되는 노드에서 시작하거나 xPath 매개 변수가 비어 있는 경우 문서 루트에서 시작하여 각 자식 노드에 대한 정보가 들어 있는 배열을 가져옵니다.

MemberwiseClone()

현재 Object의 단순 복사본을 만듭니다.

(다음에서 상속됨 Object)
ToString()

현재 개체를 나타내는 문자열을 반환합니다.

(다음에서 상속됨 Object)

적용 대상

추가 정보