XElement.NodeType Propriedade
Definição
Obtém o tipo de nó para este nó.Gets the node type for this node.
public:
virtual property System::Xml::XmlNodeType NodeType { System::Xml::XmlNodeType get(); };
public override System.Xml.XmlNodeType NodeType { get; }
member this.NodeType : System.Xml.XmlNodeType
Public Overrides ReadOnly Property NodeType As XmlNodeType
Valor da propriedade
O tipo de nó.The node type. Para objetos XElement, esse valor é Element.For XElement objects, this value is Element.
Exemplos
O exemplo a seguir usa essa propriedade para imprimir o tipo de nó de um elemento.The following example uses this property to print the node type of an element.
XElement el1 = new XElement("Root", "content");
Console.WriteLine(el1.NodeType);
Console.WriteLine();
Dim el1 As XElement = <Root>content</Root>
Console.WriteLine(el1.NodeType.ToString())
Console.WriteLine()
Esse exemplo gera a saída a seguir:This example produces the following output:
Element
Comentários
Como todas as classes que derivam de XObject contêm uma NodeType propriedade, você pode escrever um código que opere em coleções de subclasse concreta de XObject .Because all classes that derive from XObject contain a NodeType property, you can write code that operates on collections of concrete subclass of XObject. Seu código pode, então, testar o tipo de nó de cada nó na coleção.Your code can then test for the node type of each node in the collection.