Definition
Assembly: CloudNimble.XmlEssentials.dll Namespace: CloudNimble.Text.Xml Inheritance: System.EnumSyntax
Summary
Specifies how a Utf8XmlReader handles comments.Usage
SetXmlReaderOptions.CommentHandling to choose what a Utf8XmlReader does when it reads a comment.
The sample reads one document twice, first with the default options and then with comments skipped (and white space between elements left out):
Remarks
XmlCommentHandling.Allow is the zero value of the enumeration, so it is the default wherever a comment handling value is not set: in XmlReaderOptions and XmlDocumentOptions, whether they are created withnew or as default. Comments are kept
by default so that XML that is read and written back does not lose them.
XmlSerializerOptions.ReadCommentHandling defaults to XmlCommentHandling.Skip, because a
comment has no place in an object.
Considerations
Allowis the zero value, and the default.new XmlReaderOptions(),default(XmlReaderOptions), a reader created without options, andnew XmlReaderState()all report comments. Comments are kept by default so that XML that’s read and written back doesn’t lose them.- The serializer’s default is different.
XmlSerializerOptions.ReadCommentHandlingdefaults toSkip, because a comment has no place in an object. - A skipped comment is still checked. A comment that contains
--, or that’s longer thanXmlReaderOptions.MaxCommentByteCount, throws anXmlExceptionunder every setting. - The setting covers the whole document, including comments before and after the root element.
XmlDocumentuses the same enumeration.XmlDocumentOptions.CommentHandlingalso defaults toAllow.
Values
Related APIs
- CloudNimble.Text.Xml.XmlReaderOptions
- CloudNimble.Text.Xml.XmlDocumentOptions
- CloudNimble.Text.Xml.XmlTokenType
- CloudNimble.Text.Xml.Utf8XmlReader
- CloudNimble.Text.Xml.XmlWhitespaceHandling