SyntaxKind Enum

Identifies what a node, token, or trivium in an XML tree is.

public enum SyntaxKind

Example

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

NameValueDescription
None0
List1A list of nodes or tokens. Reserved for the list node the shared layer builds.
XmlDocument2
XmlElement3
XmlEmptyElement4
XmlElementStartTag5
XmlElementEndTag6
XmlAttribute7
XmlText8
XmlComment9
XmlCDataSection10
XmlDeclaration11
XmlProcessingInstruction12
XmlDocumentType13
XmlSkippedText14
LessThanToken15
GreaterThanToken16
LessThanSlashToken17
SlashGreaterThanToken18
EqualsToken19
SingleQuoteToken20
DoubleQuoteToken21
LessThanQuestionToken22
LessThanQuestionXmlToken23
QuestionGreaterThanToken24
XmlCommentStartToken25
XmlCommentEndToken26
CDataStartToken27
CDataEndToken28
DocumentTypeStartToken29
IdentifierToken30
AttributeValueToken31
TextToken32
CommentToken33
CDataToken34
ProcessingInstructionDataToken35
DocumentTypeContentToken36
BadToken37
EndOfFileToken38
WhitespaceTrivia39
EndOfLineTrivia40
SkippedTextTrivia41Text inside a tag that the parser could not read, kept so the document still reproduces its source.