XmlDocumentSchema Class
TOC
Collapse the table of content
Expand the table of content

XmlDocumentSchema Class

Represents the structure, or schema, of an XmlDocument. This class cannot be inherited.

Namespace:  System.Web.UI.Design
Assembly:  System.Design (in System.Design.dll)

'Declaration
<SecurityPermissionAttribute(SecurityAction.Demand, Flags := SecurityPermissionFlag.UnmanagedCode)> _
Public NotInheritable Class XmlDocumentSchema _
	Implements IDataSourceSchema
'Usage
Dim instance As XmlDocumentSchema

The XmlDocumentSchema class is used by custom control designer components to list the structural elements of an XML document at design time. Use the XmlDocumentSchema class to populate lists of document elements to allow users to select document elements in UI features at design time.

The following code example uses an XmlDocumentSchema object to display the structure of an XML document in a TreeView control.

Imports Microsoft.VisualBasic
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

System.Object
  System.Web.UI.Design.XmlDocumentSchema

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0

Community Additions

ADD
Show:
© 2016 Microsoft