SyntaxKind Enum
Identifies what a node, token, or trivium in an XML tree is.
public enum SyntaxKindExample
var tree = XmlSyntaxTree.ParseText("<root><item /><item>text</item></root>");
var elementCount = 0;
foreach (var node in tree.GetRoot().DescendantNodes())
{
if (node.Kind() == SyntaxKind.XmlElement)
{
// handle element
elementCount++;
}
}
// <item /> is an XmlEmptyElement, so only <root> and the second <item> are counted
Assert.Equal(2, elementCount);Fields
| Name | Value | Description |
|---|---|---|
None | 0 | |
List | 1 | A list of nodes or tokens. Reserved for the list node the shared layer builds. |
XmlDocument | 2 | |
XmlElement | 3 | |
XmlEmptyElement | 4 | |
XmlElementStartTag | 5 | |
XmlElementEndTag | 6 | |
XmlAttribute | 7 | |
XmlText | 8 | |
XmlComment | 9 | |
XmlCDataSection | 10 | |
XmlDeclaration | 11 | |
XmlProcessingInstruction | 12 | |
XmlDocumentType | 13 | |
XmlSkippedText | 14 | |
LessThanToken | 15 | |
GreaterThanToken | 16 | |
LessThanSlashToken | 17 | |
SlashGreaterThanToken | 18 | |
EqualsToken | 19 | |
SingleQuoteToken | 20 | |
DoubleQuoteToken | 21 | |
LessThanQuestionToken | 22 | |
LessThanQuestionXmlToken | 23 | |
QuestionGreaterThanToken | 24 | |
XmlCommentStartToken | 25 | |
XmlCommentEndToken | 26 | |
CDataStartToken | 27 | |
CDataEndToken | 28 | |
DocumentTypeStartToken | 29 | |
IdentifierToken | 30 | |
AttributeValueToken | 31 | |
TextToken | 32 | |
CommentToken | 33 | |
CDataToken | 34 | |
ProcessingInstructionDataToken | 35 | |
DocumentTypeContentToken | 36 | |
BadToken | 37 | |
EndOfFileToken | 38 | |
WhitespaceTrivia | 39 | |
EndOfLineTrivia | 40 | |
SkippedTextTrivia | 41 | Text inside a tag that the parser could not read, kept so the document still reproduces its source. |