Skip to main content

Definition

Assembly: CloudNimble.XmlEssentials.dll Namespace: CloudNimble.Text.Xml Inheritance: System.Enum

Syntax

Summary

Specifies the type of token that a Utf8XmlReader is positioned on in a UTF-8 XML document.

Usage

After each call to Utf8XmlReader.Read that returns true, Utf8XmlReader.TokenType says what the reader is on. Switch on it to decide which members to read.
For the document below, the loop prints the token types in the order shown.
View the complete sample on GitHub

Remarks

Empty elements (<e/>) are reported as XmlTokenType.StartElement with Utf8XmlReader.IsEmptyElement set. The reader does not synthesize an XmlTokenType.EndElement token. Callers must check Utf8XmlReader.IsEmptyElement before expecting a matching end tag.

Considerations

  • StartElement covers <e> and <e/>. For an empty element, Utf8XmlReader.IsEmptyElement is true and no EndElement token follows. Check it wherever you count depth or wait for an end tag.
  • Attribute never comes from Read. TokenType is Attribute only between a call to MoveToNextAttribute that returns true and the next call to MoveToElement or Read.
  • Comment is reported by default. Set XmlReaderOptions.CommentHandling to XmlCommentHandling.Skip when you don’t want comments.
  • White space between elements is a Text token by default. Set XmlReaderOptions.WhitespaceHandling to XmlWhitespaceHandling.Insignificant when you don’t want it. The example in the usage section does both. White-space-only text that is content, such as the whole of <e> </e>, is a Text token under every setting.
  • Text and CData carry the same kind of value. They differ only in how the document wrote it. Handle them together unless you need to know which form was used.
  • XmlDeclaration can only be the first token. A document doesn’t have to have one.
  • None means there’s no current token: before the first Read, and after Read returns false at the end of the document.
  • A document type declaration throws. The reader rejects <!DOCTYPE with an XmlException (DTD is not allowed.) instead of reporting it.

Values

  • CloudNimble.Text.Xml.Utf8XmlReader
  • CloudNimble.Text.Xml.XmlReaderOptions
  • CloudNimble.Text.Xml.XmlCommentHandling
  • CloudNimble.Text.Xml.XmlWhitespaceHandling
  • CloudNimble.Text.Xml.XmlValueKind