Definition
Assembly: CloudNimble.XmlEssentials.dll Namespace: CloudNimble.Text.Xml Inheritance: System.ValueTypeSyntax
Summary
Provides a high-performance API for forward-only, read-only access to UTF-8 encoded XML text.Usage
Create a reader over UTF-8 bytes (au8 literal, a byte[], a ReadOnlySpan<byte>, or a ReadOnlySequence<byte>) and call Read until it returns false. After each call, TokenType says what the reader is on.
Pass an
XmlReaderOptions to the constructor to leave out comments and the white space between elements, to read a fragment, or to change a limit. By default the reader reports both, so that a document can be written back unchanged. The loop above isn’t affected, because it acts only on start tags.
For a walk through every feature, see How to read XML with Utf8XmlReader.
Remarks
The reader is aref struct that reads the text one token at a time, in the manner
of Utf8JsonReader.
Empty elements are reported as XmlTokenType.StartElement with
Utf8XmlReader.IsEmptyElement set to true. The reader does not synthesize an
XmlTokenType.EndElement token. Callers must check
Utf8XmlReader.IsEmptyElement before expecting a matching end tag.
The xmlns attributes of a start tag bind before the element name is resolved. Unprefixed
attributes are in no namespace. Unprefixed elements use the default namespace.
The XML declaration, when present, must be the first token in the document (after an optional BOM).
Examples
Each example is a sample in the repository whose output is checked by a test.Read typed values
TheGet* methods parse a value in place and throw an XmlException when it isn’t valid for the type. The TryGet* methods return false instead.
Read names with their namespaces
Skip an element
XmlReaderState.
Best Practices
- Compare names and values as UTF-8.
reader.LocalNameEquals("Item"u8)andreader.ValueTextEquals("yes"u8)compare bytes with bytes.GetString()followed by==creates a string for every comparison. - Match on the namespace URI and the local name, not on the prefix. The producer of a document is free to choose any prefix.
- Check
IsEmptyElementon every start tag. An empty element has noEndElementtoken, so code that counts depth or waits for an end tag has to know. - Read a value only on a token that has one. Use the value members on
Text,CData,Attribute,Comment, andProcessingInstructiontokens. - Use
TryGet*when a bad value is something you expect. AGet*method throws anXmlExceptionwhen a value isn’t valid, which fits values that must be right. - Copy what you keep. A span from the reader is valid until the reader moves.
- Set
CommentHandlingtoSkipandWhitespaceHandlingtoInsignificantin a loop that only wants data. By default the reader reports comments and the white space between elements, so that a document can be written back unchanged. - Pass the reader with
refto a helper method that advances it. - Give the reader a scratch buffer on a hot path. With one that’s large enough for the document, reading allocates nothing.
- Take
CurrentStateonce per block. It copies the open element names and namespace bindings, so it allocates.
Patterns
These are the shapes that code using the reader takes most often.Token loop
while (reader.Read()) with a switch on TokenType is the basic shape, as with Utf8JsonReader. Handle StartElement and check IsEmptyElement before you expect content or an end tag.
Attribute walk
On a start tag, callMoveToNextAttribute until it returns false. While the reader is on an attribute, TokenType is Attribute and the name and value members describe the attribute. Namespace declarations are part of the walk. MoveToElement returns to the start tag, and Read continues after the start tag whether or not you call it.
Element with a value
After a start tag that you know holds text, callRead once and use a Get* or TryGet* method. For an element that can be empty, check that the token is Text or CData first.
Look ahead
Copy the reader (var lookahead = reader;), read ahead with the copy inside the current element, and then drop the copy or carry on with it. A copy shares working memory with the original, so don’t advance both in turn.
Read in blocks
Construct a reader for each block withisFinalBlock and the state from the previous reader. When Read returns false, save CurrentState, keep the bytes after BytesConsumed, and add more data. The complete loop is in the example for XmlReaderState.
Custom converter
XmlConverter<T>.Read receives the reader by reference, positioned on the value to convert. See Custom converters.
Considerations
Know the following before you build on the reader.It’s a ref struct
A reader can’t be stored in a field of a class, captured by a lambda, or used across anawait or a yield return. Passing it by value copies it. It isn’t thread safe.
Lifetime of spans
ValueSpan, LocalNameSpan, PrefixSpan, and NamespaceUriSpan point into your input, or into a buffer that the reader reuses for the next decoded value. They’re valid until the reader moves. On a start tag or an end tag, ValueSpan is empty.
Allocation
Reading tokens, comparing names, and parsing typed values don’t allocate.GetString, GetComment, and GetBytesFromBase64 return new objects. The reader allocates working memory, which it keeps for the tokens that follow, when a value has to be decoded, when a start tag has more than eight attributes, when more than eight namespace declarations are in scope, or when elements nest more than eight deep. The constructors that take a scratch buffer use that buffer first. A sequence of more than one segment is copied into one array before it’s read, and CurrentState allocates.
What it checks
The reader checks that the document is well formed as it reads, including names, characters, matching end tags, duplicate attributes, and namespace declarations. It doesn’t validate against a DTD or a schema. An error is thrown when the reader reaches it, which can be after your code has handled the tokens before it.What it rejects
A document type declaration, an encoding other than UTF-8, and any entity other than the five predefined ones throw anXmlException. See XML conformance.
Differences from Utf8JsonReader
- An empty element is one token with
IsEmptyElementset. There’s no end token for it. - Attributes aren’t tokens in the
Readsequence. You visit them withMoveToNextAttribute. - The value is always in
ValueSpan. A multi-segment sequence is copied into one buffer before it is read. - A copy of a reader shares working memory with the original.
XmlReaderStateholds the open elements and namespace bindings, so taking it allocates.
Differences from System.Xml.XmlReader
- The input is UTF-8 bytes in memory, not a stream or a
TextReader, and there’s no asynchronousRead. - DTDs are always rejected, and there’s no validation, no entity resolution, and no
XmlResolver. - Names and values are spans of bytes. Strings are created only when you ask for one.
- The defaults are alike: both readers report comments and white space between elements unless you turn them off.
Constructors
.ctor
Initializes a new instance of the Utf8XmlReader struct that processes a read-only span of UTF-8 encoded text that holds a complete document, using the default options.Syntax
Parameters
Remarks
The default options report comments (XmlCommentHandling.Allow) and whitespace-only text between elements (XmlWhitespaceHandling.Significant) as tokens..ctor
Initializes a new instance of the Utf8XmlReader struct that processes a read-only span of UTF-8 encoded text that holds a complete document, using the specified options.Syntax
Parameters
Exceptions
.ctor
Initializes a new instance of the Utf8XmlReader struct that processes a read-only span of UTF-8 encoded text and indicates whether the input contains all the text to process.Syntax
Parameters
Exceptions
Remarks
AdefaultXmlReaderState holds the default options, which report
comments and whitespace-only text between elements as tokens.
.ctor
Initializes a new instance of the Utf8XmlReader struct that processes a read-only span of UTF-8 encoded text that holds a complete document, using the specified options and a caller-supplied buffer as working memory.Syntax
Parameters
Exceptions
Examples
Remarks
A reader needs memory of its own in four cases: a value that holds a character or entity reference, or a line end other than LF, is decoded into a buffer; a start tag with more than eight attributes needs a larger attribute table; so do more than eight namespace declarations in scope; and so do elements nested more than eight deep. Without scratch each of those is an array allocated for this reader. With it, the reader takes the memory from scratch and allocates only once that is used up, so a buffer of any size is safe and a larger one saves more. Copies of the reader share the buffer, as they share the arrays a reader without one allocates. A copy may look ahead within the element the original is on and then be dropped, or the copy may be the one that carries on. Do not advance two copies in turn, and do not go back to the original once a copy has read past the end of the element the original is on..ctor
Initializes a new instance of the Utf8XmlReader struct that processes a read-only span of UTF-8 encoded text, indicates whether the input contains all the text to process, and uses a caller-supplied buffer as working memory.Syntax
Parameters
Exceptions
Remarks
See Utf8XmlReader..ctor for what the buffer is used for. AdefaultXmlReaderState holds the default options, which report
comments and whitespace-only text between elements as tokens.
.ctor
Initializes a new instance of the Utf8XmlReader struct that processes a read-only sequence of UTF-8 encoded text that holds a complete document, using the default options.Syntax
Parameters
Remarks
The default options report comments and whitespace-only text between elements as tokens..ctor
Initializes a new instance of the Utf8XmlReader struct that processes a read-only sequence of UTF-8 encoded text that holds a complete document, using the specified options.Syntax
Parameters
Exceptions
.ctor
Initializes a new instance of the Utf8XmlReader struct that processes a read-only sequence of UTF-8 encoded text and indicates whether the input contains all the text to process.Syntax
Parameters
Exceptions
Remarks
AdefaultXmlReaderState holds the default options, which report
comments and whitespace-only text between elements as tokens.
.ctor Inherited
Inherited from
System.ValueTypeSyntax
.ctor Inherited
Inherited from
objectSyntax
Properties
AttributeCount
Gets the number of attributes on the current start tag.Syntax
Property Value
Type:int
The number of attributes on the current start tag, including namespace declarations.
BytesConsumed
Gets the total number of bytes consumed so far by this instance of the Utf8XmlReader.Syntax
Property Value
Type:long
The number of bytes consumed from the current buffer.
CurrentDepth
Gets the depth of the current token.Syntax
Property Value
Type:int
The number of elements that the current token is inside.
Examples
Remarks
The root element is at depth 0, and so is anything before or after it. A start tag, its end tag, and an empty element in the same place are at the same depth, and the content of an element is one deeper. An attribute is at the depth of its element. This is the depth thatXmlReader.Depth and
Utf8JsonReader.CurrentDepth report.
CurrentState
Gets the current Utf8XmlReader state to pass to a Utf8XmlReader constructor with more data.Syntax
Property Value
Type:CloudNimble.Text.Xml.XmlReaderState
The state to resume reading from.
Remarks
The state is opaque. The public surface of XmlReaderState is XmlReaderState.Options only. The reader’s progress is copied into the state, so two readers never share mutable stacks.HasAttributes
Gets a value that indicates whether the current start tag has attributes.Syntax
Property Value
Type:bool
true if the current start tag has at least one attribute; otherwise,
false.
IsEmptyElement
Gets a value that indicates whether the current start tag is an empty element (<e/>).
Syntax
Property Value
Type:bool
true if the current start tag is an empty element; otherwise,
false.
IsFinalBlock
Gets a value that indicates whether all the XML data was provided or there is more data to come.Syntax
Property Value
Type:bool
true if the reader was constructed with the input span or sequence containing
the entire XML data to process; false if the reader was constructed with an
input span or sequence that may contain partial XML data with more data to follow.
LocalNameSpan
Gets the local name of the current element or attribute.Syntax
Property Value
Type:System.ReadOnlySpan<byte>
The local name, without a prefix, as UTF-8 bytes.
NamespaceUriSpan
Gets the namespace URI of the current element or attribute.Syntax
Property Value
Type:System.ReadOnlySpan<byte>
The namespace URI as UTF-8 bytes, or an empty span if the name is in no namespace or the current
token is not a start tag, an end tag, or an attribute.
Remarks
Unprefixed attributes are in no namespace. Unprefixed elements use the default namespace.Position
Gets the current SequencePosition within the provided UTF-8 encoded input ReadOnlySequence1](https://learn.microsoft.com/dotnet/api/system.buffers.readonlysequence-1), or a default [SequencePosition](https://learn.microsoft.com/dotnet/api/system.sequenceposition) if the [Utf8XmlReader](/xmlessentials/api-reference/CloudNimble/Text/Xml/Utf8XmlReader) struct was constructed with a [ReadOnlySpan1.
Syntax
Property Value
Type:System.SequencePosition
The position in the input sequence that the reader has consumed up to, or a default
SequencePosition if the input is a span.
PrefixSpan
Gets the namespace prefix of the current element or attribute.Syntax
Property Value
Type:System.ReadOnlySpan<byte>
The prefix as UTF-8 bytes, or an empty span if the name has no prefix.
TokenStartIndex
Gets the index that the last processed XML token starts at in the document.Syntax
Property Value
Type:long
The zero-based byte offset of the token from the start of the document. When the document is read
in several blocks, the offset counts the bytes of the earlier blocks.
TokenType
Gets the type of the last processed XML token in the UTF-8 encoded XML text.Syntax
Property Value
Type:CloudNimble.Text.Xml.XmlTokenType
One of the enumeration values that indicates the type of the current token. After
Utf8XmlReader.MoveToNextAttribute returns true, this is
XmlTokenType.Attribute.
ValueIsEscaped
Gets a value that indicates whether the current value differs from its bytes in the input.Syntax
Property Value
Type:bool
true if the value held character or entity references, or line ends that were
normalized; otherwise, false.
ValueSpan
Gets the value of the last processed token as a read-only span of UTF-8 bytes.Syntax
Property Value
Type:System.ReadOnlySpan<byte>
The UTF-8 bytes of the current token value. If the value held character or entity references, or
line ends that had to be normalized, the span holds the decoded value. Otherwise, it is a slice of
the input.
Version
Gets the XML version that is in force for the document.Syntax
Property Value
Type:CloudNimble.Text.Xml.XmlVersion
One of the enumeration values that indicates the version named in the XML declaration. The default
is XmlVersion.Version10, which applies until a declaration is read and when the
document has none.
Methods
CopyString
Copies the current token value from the source, with references decoded, as UTF-8 text to a destination buffer.Syntax
Parameters
Returns
Type:int
The number of bytes written to utf8Destination.
Exceptions
CopyString
Copies the current token value from the source, with references decoded, as UTF-16 text to a destination buffer.Syntax
Parameters
Returns
Type:int
The number of characters written to destination.
Exceptions
Equals Override
Inherited from
System.ValueTypeSyntax
Parameters
Returns
Type:bool
Equals Inherited Virtual
Inherited from
objectSyntax
Parameters
Returns
Type:bool
Equals Inherited
Inherited from
objectSyntax
Parameters
Returns
Type:bool
GetBoolean
Parses the current text, CDATA, or attribute value from the source as an XSDboolean.
Syntax
Returns
Type:bool
true if the value is true or 1; false if the
value is false or 0.
Exceptions
GetByte
Parses the current token value from the source as a Byte (xs:unsignedByte).
Syntax
Returns
Type:byte
The value of the current token, parsed as an 8-bit unsigned integer.
Exceptions
GetBytesFromBase64
Parses the current token value from the source as XSDbase64Binary and decodes it into a
byte array.
Syntax
Returns
Type:byte[]
The byte array that the Base64 encoded value represents.
Exceptions
GetComment
Reads the content of the current XmlTokenType.Comment token from the source, transcoded as a String.Syntax
Returns
Type:string
The comment text, without the surrounding <!-- --> delimiters.
Exceptions
GetDateOnly
Parses the current token value from the source as a DateOnly (xs:date).
Syntax
Returns
Type:System.DateOnly
The date that the value of the current token represents.
Exceptions
GetDateTime
Parses the current token value from the source as a DateTime (xs:dateTime).
Syntax
Returns
Type:System.DateTime
The date and time that the value of the current token represents.
Exceptions
GetDateTimeOffset
Parses the current token value from the source as a DateTimeOffset (xs:dateTime with an offset).
Syntax
Returns
Type:System.DateTimeOffset
The date, time, and offset that the value of the current token represents.
Exceptions
GetDecimal
Parses the current token value from the source as a Decimal (xs:decimal).
Syntax
Returns
Type:decimal
The value of the current token, parsed as a decimal number.
Exceptions
GetDouble
Parses the current token value from the source as a Double (xs:double),
including INF, -INF, and NaN.
Syntax
Returns
Type:double
The value of the current token, parsed as a double-precision floating-point number.
Exceptions
GetGuid
Parses the current token value from the source as a Guid.Syntax
Returns
Type:System.Guid
The GUID that the value of the current token represents.
Exceptions
GetHashCode Override
Inherited from
System.ValueTypeSyntax
Returns
Type:int
GetHashCode Inherited Virtual
Inherited from
objectSyntax
Returns
Type:int
GetInt16
Parses the current token value from the source as a Int16 (xs:short).
Syntax
Returns
Type:short
The value of the current token, parsed as a 16-bit signed integer.
Exceptions
GetInt32
Parses the current token value from the source as an Int32 (xs:int).
Syntax
Returns
Type:int
The value of the current token, parsed as a 32-bit signed integer.
Exceptions
GetInt64
Parses the current token value from the source as a Int64 (xs:long).
Syntax
Returns
Type:long
The value of the current token, parsed as a 64-bit signed integer.
Exceptions
GetNil
Determines whether the current start element is marked nil withxsi:nil="true" or
xsi:nil="1".
Syntax
Returns
Type:bool
true if the element has an xsi:nil attribute whose value is true or
1; otherwise, false.
Exceptions
Remarks
The local namenil must be in the XML Schema instance namespace.
An unprefixed nil attribute is in no namespace and does not count.
GetSByte
Parses the current token value from the source as an SByte (xs:byte).
Syntax
Returns
Type:sbyte
The value of the current token, parsed as an 8-bit signed integer.
Exceptions
GetSingle
Parses the current token value from the source as a Single (xs:float),
including INF, -INF, and NaN.
Syntax
Returns
Type:float
The value of the current token, parsed as a single-precision floating-point number.
Exceptions
GetString
Reads the current token value from the source, with references decoded, and transcodes it as a String.Syntax
Returns
Type:string?
The token value transcoded to a string. The result is never null. It is an empty
string when the value is empty.
GetTimeOnly
Parses the current token value from the source as a TimeOnly (xs:time).
Syntax
Returns
Type:System.TimeOnly
The time of day that the value of the current token represents.
Exceptions
GetTimeSpan
Parses the current token value from the source as a TimeSpan (xs:duration).
Syntax
Returns
Type:System.TimeSpan
The duration that the value of the current token represents.
Exceptions
GetType Inherited
Inherited from
objectSyntax
Returns
Type:System.Type
GetUInt16
Parses the current token value from the source as a UInt16 (xs:unsignedShort).
Syntax
Returns
Type:ushort
The value of the current token, parsed as a 16-bit unsigned integer.
Exceptions
GetUInt32
Parses the current token value from the source as a UInt32 (xs:unsignedInt).
Syntax
Returns
Type:uint
The value of the current token, parsed as a 32-bit unsigned integer.
Exceptions
GetUInt64
Parses the current token value from the source as a UInt64 (xs:unsignedLong).
Syntax
Returns
Type:ulong
The value of the current token, parsed as a 64-bit unsigned integer.
Exceptions
LocalNameEquals
Compares the UTF-8 encoded text in a read-only byte span to the local name of the current element or attribute and returns a value that indicates whether they match.Syntax
Parameters
Returns
Type:bool
true if the local name matches utf8LocalName byte for byte;
otherwise, false.
LocalNameEquals
Compares the text in a read-only character span to the local name of the current element or attribute and returns a value that indicates whether they match.Syntax
Parameters
Returns
Type:bool
true if the local name matches localName; otherwise,
false.
LocalNameEquals
Compares the text in a string to the local name of the current element or attribute and returns a value that indicates whether they match.Syntax
Parameters
Returns
Type:bool
true if the local name matches localName; otherwise,
false.
MemberwiseClone Inherited
Inherited from
objectSyntax
Returns
Type:object
MoveToElement
Moves the reader from the current attribute back to the start element that holds it.Syntax
Remarks
After this call, Utf8XmlReader.MoveToNextAttribute starts again at the first attribute.MoveToNextAttribute
Moves the reader to the next attribute on the current start tag.Syntax
Returns
Type:bool
true if the reader moved to an attribute; false if the current
token is not a start tag or the start tag has no more attributes.
NamespaceUriEquals
Compares the UTF-8 encoded text in a read-only byte span to the namespace URI of the current element or attribute and returns a value that indicates whether they match.Syntax
Parameters
Returns
Type:bool
true if the namespace URI matches utf8NamespaceUri byte for
byte; otherwise, false.
NamespaceUriEquals
Compares the text in a read-only character span to the namespace URI of the current element or attribute and returns a value that indicates whether they match.Syntax
Parameters
Returns
Type:bool
true if the namespace URI matches namespaceUri; otherwise,
false.
NamespaceUriEquals
Compares the text in a string to the namespace URI of the current element or attribute and returns a value that indicates whether they match.Syntax
Parameters
Returns
Type:bool
true if the namespace URI matches namespaceUri; otherwise,
false.
Read
Reads the next XML token from the input source.Syntax
Returns
Type:bool
true if the token was read successfully; otherwise, false.
The result is false at the end of a complete document, and when more data is
required and Utf8XmlReader.IsFinalBlock is false.
Exceptions
ReferenceEquals Inherited
Inherited from
objectSyntax
Parameters
Returns
Type:bool
Skip
Skips the children of the current XML element.Syntax
Exceptions
Remarks
When the current token is a start element, the reader moves to its end tag. On an empty element, and on any token that is not a start element, this method does nothing, asUtf8JsonReader.Skip
does on a value. The next Utf8XmlReader.Read moves to the following token.
ToString Override
Inherited from
System.ValueTypeSyntax
Returns
Type:string?
ToString Inherited Virtual
Inherited from
objectSyntax
Returns
Type:string?
TryGetByte
Attempts to read the current value as an unsigned 8-bit integer (xs:unsignedByte).
Syntax
Parameters
Returns
Type:bool
true if the entire token value can be parsed as the requested type; otherwise,
false.
TryGetBytesFromBase64
Attempts to read the current value as XSDbase64Binary.
Syntax
Parameters
Returns
Type:bool
true if the entire token value is valid Base64 and was decoded; otherwise,
false.
TryGetDateOnly
Attempts to read the current value as XSDdate.
Syntax
Parameters
Returns
Type:bool
true if the entire token value can be parsed as the requested type; otherwise,
false.
TryGetDateTime
Attempts to read the current value as XSDdateTime.
Syntax
Parameters
Returns
Type:bool
true if the entire token value can be parsed as the requested type; otherwise,
false.
TryGetDateTimeOffset
Attempts to read the current value as XSDdateTime with an offset.
Syntax
Parameters
Returns
Type:bool
true if the entire token value can be parsed as the requested type; otherwise,
false.
TryGetDecimal
Attempts to read the current value as XSDdecimal. Exponent notation is rejected.
Syntax
Parameters
Returns
Type:bool
true if the entire token value can be parsed as the requested type; otherwise,
false.
TryGetDouble
Attempts to read the current value as XSDdouble, including INF, -INF, and NaN.
Syntax
Parameters
Returns
Type:bool
true if the entire token value can be parsed as the requested type; otherwise,
false.
TryGetGuid
Attempts to read the current value as a GUID.Syntax
Parameters
Returns
Type:bool
true if the entire token value can be parsed as the requested type; otherwise,
false.
TryGetInt16
Attempts to read the current value as a 16-bit integer (xs:short).
Syntax
Parameters
Returns
Type:bool
true if the entire token value can be parsed as the requested type; otherwise,
false.
TryGetInt32
Attempts to read the current value as a 32-bit integer (xs:int).
Syntax
Parameters
Returns
Type:bool
true if the entire token value can be parsed as the requested type; otherwise,
false.
TryGetInt64
Attempts to read the current value as a 64-bit integer (xs:long).
Syntax
Parameters
Returns
Type:bool
true if the entire token value can be parsed as the requested type; otherwise,
false.
TryGetSByte
Attempts to read the current value as a signed 8-bit integer (xs:byte).
Syntax
Parameters
Returns
Type:bool
true if the entire token value can be parsed as the requested type; otherwise,
false.
TryGetSingle
Attempts to read the current value as XSDfloat.
Syntax
Parameters
Returns
Type:bool
true if the entire token value can be parsed as the requested type; otherwise,
false.
TryGetTimeOnly
Attempts to read the current value as XSDtime.
Syntax
Parameters
Returns
Type:bool
true if the entire token value can be parsed as the requested type; otherwise,
false.
TryGetTimeSpan
Attempts to read the current value as XSDduration. Year and month components are rejected.
Syntax
Parameters
Returns
Type:bool
true if the entire token value can be parsed as the requested type; otherwise,
false.
TryGetUInt16
Attempts to read the current value as an unsigned 16-bit integer (xs:unsignedShort).
Syntax
Parameters
Returns
Type:bool
true if the entire token value can be parsed as the requested type; otherwise,
false.
TryGetUInt32
Attempts to read the current value as an unsigned 32-bit integer (xs:unsignedInt).
Syntax
Parameters
Returns
Type:bool
true if the entire token value can be parsed as the requested type; otherwise,
false.
TryGetUInt64
Attempts to read the current value as an unsigned 64-bit integer (xs:unsignedLong).
Syntax
Parameters
Returns
Type:bool
true if the entire token value can be parsed as the requested type; otherwise,
false.
TrySkip
Tries to skip the children of the current XML element.Syntax
Returns
Type:bool
true if there was enough data for the children to be skipped successfully;
otherwise, false.
Exceptions
Remarks
When the current token is a start element, the reader moves to its end tag. On an empty element this method does nothing and returnstrue.
When the element is not all in the current block, the reader is put back on its start tag, as
Utf8JsonReader.TrySkip does, so the caller can supply more data and skip or read it again.
When the current token is not a start element, this method does nothing and returns
true: the token has no children to skip.
ValueTextEquals
Compares the UTF-8 encoded text in a read-only byte span to the decoded XML token value in the source and returns a value that indicates whether they match.Syntax
Parameters
Returns
Type:bool
true if the XML token value in the source matches the UTF-8 encoded lookup text;
otherwise, false.
ValueTextEquals
Compares the text in a read-only character span to the decoded XML token value in the source and returns a value that indicates whether they match.Syntax
Parameters
Returns
Type:bool
true if the XML token value in the source matches the lookup text; otherwise,
false.
ValueTextEquals
Compares the text in a string to the decoded XML token value in the source and returns a value that indicates whether they match.Syntax
Parameters
Returns
Type:bool
true if the XML token value in the source matches the lookup text; otherwise,
false.
Related APIs
- CloudNimble.Text.Xml.XmlReaderOptions
- CloudNimble.Text.Xml.XmlReaderState
- CloudNimble.Text.Xml.XmlTokenType
- CloudNimble.Text.Xml.XmlCommentHandling
- CloudNimble.Text.Xml.XmlWhitespaceHandling
- CloudNimble.Text.Xml.XmlVersion
- CloudNimble.Text.Xml.XmlException
- CloudNimble.Text.Xml.Utf8XmlWriter
- CloudNimble.Text.Xml.XmlDocument
- CloudNimble.Text.Xml.Serialization.XmlConverter