Gets the node type for this XObject. : XObject « XML LINQ « C# / C Sharp






Gets the node type for this XObject.

 

using System.Xml;
using System;
using System.Xml.Linq;

class Program
{
    static void Main(string[] args)
    {

        XDocument xmlTree = new XDocument(
            new XComment("a comment"),
            new XProcessingInstruction("xml-stylesheet", "type=\"text/xsl\" href=\"hello.xsl\""),
            new XElement("Root",
                new XAttribute("Att", "attContent"),
                new XElement("Child1", new XCData("CDATA content")),
                new XElement("Child2", new XText("Text content"))
            )
        );

        foreach (XNode node in xmlTree.DescendantNodes())
        {
            Console.WriteLine(node.NodeType);
            if (node.NodeType == XmlNodeType.Element)
            {
                foreach (XAttribute att in ((XElement)node).Attributes())
                    Console.WriteLine(att.NodeType);
            }
        }
    }
}

   
  








Related examples in the same category

1.Adds an object to the annotation list of this XObject.
2.Gets the first annotation object of the specified type from this XObject.
3.Get the first annotation object of the specified type from this XObject.
4.Gets a collection of annotations of the specified type for this XObject.
5.Gets the base URI for this XObject.
6.Raise event when this XObject or any of its descendants are changing
7.Raise event when this XObject or any of its descendants are changed
8.Check the specific events