XCData.NodeType Property
[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]
Gets the node type for this node.
Assembly: System.Xml.Linq (in System.Xml.Linq.dll)
The following example creates an XML tree that contains various types of nodes. It then iterates through the tree, and prints the node type of each node.
StringBuilder output = new StringBuilder(); // Note that XNode uses XmlNodeType, which is in the System.Xml namespace. 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()) { output.Append(node.NodeType + Environment.NewLine); output.Append(Environment.NewLine); if (node.NodeType == XmlNodeType.Element) { foreach (XAttribute att in ((XElement)node).Attributes()) output.Append(att.NodeType + Environment.NewLine); } } OutputTextBlock.Text = output.ToString();
Show: