XmlDocumentSchema Classe
Definição
Importante
Algumas informações se referem a produtos de pré-lançamento que podem ser substancialmente modificados antes do lançamento. A Microsoft não oferece garantias, expressas ou implícitas, das informações aqui fornecidas.
Representa a estrutura ou o esquema de um XmlDocument. Essa classe não pode ser herdada.
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
- Herança
-
XmlDocumentSchema
- Implementações
Exemplos
O exemplo de código a seguir usa um XmlDocumentSchema objeto para exibir a estrutura de um documento XML em um TreeView controle .
// 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
Comentários
A XmlDocumentSchema classe é usada por componentes personalizados do designer de controle para listar os elementos estruturais de um documento XML em tempo de design. Use a classe XmlDocumentSchema para preencher listas de elementos de documento para permitir que os usuários selecionem elementos de documento em recursos de interface do usuário em tempo de design.
Construtores
| XmlDocumentSchema(XmlDocument, String) |
Cria uma instância da classe XmlDocumentSchema usando um XmlDocument especificado e uma cadeia de caracteres XPath. |
Métodos
| Equals(Object) |
Determina se o objeto especificado é igual ao objeto atual. (Herdado de Object) |
| GetHashCode() |
Serve como a função de hash padrão. (Herdado de Object) |
| GetType() |
Obtém o Type da instância atual. (Herdado de Object) |
| GetViews() |
Obtém uma matriz que contém informações sobre cada nó filho, começando no nó identificado pelo parâmetro |
| MemberwiseClone() |
Cria uma cópia superficial do Object atual. (Herdado de Object) |
| ToString() |
Retorna uma cadeia de caracteres que representa o objeto atual. (Herdado de Object) |