XmlDocumentSchema Class
Represents the structure, or schema, of an XmlDocument. This class cannot be inherited.
Assembly: System.Design (in System.Design.dll)
| Name | Description | |
|---|---|---|
![]() | XmlDocumentSchema(XmlDocument, String) | Creates an instance of the XmlDocumentSchema class using a specified XmlDocument and an XPath string. |
| Name | Description | |
|---|---|---|
![]() | Equals(Object) | Determines whether the specified object is equal to the current object.(Inherited from Object.) |
![]() | GetHashCode() | Serves as the default hash function. (Inherited from Object.) |
![]() | GetType() | |
![]() | GetViews() | Gets an array containing information about each child node starting at the node identified by the xPath parameter in the constructor, or each child node starting at the document root if the xPath parameter is empty. |
![]() | ToString() | Returns a string that represents the current object.(Inherited from Object.) |
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
Available since 2.0
Any public static ( Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
