Skip to main content

Definition

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

Syntax

Summary

Represents the XML declaration captured when an XmlDocument is parsed.

Usage

XmlDeclarationInfo is what XmlDocument keeps of a document’s XML declaration: the version, the encoding, and the standalone flag. Read it from XmlDocument.Declaration, which is null when the document has no declaration.
View the complete sample on GitHub See How to use XmlDocument for the rest of the document API.

Remarks

The value is immutable. Mutable trees use CloudNimble.Text.Xml.Nodes.XmlDeclarationNode instead.

Considerations

  • The values are normalized, not copied from the source. For a parsed document, Version is 1.0 or 1.1, and Encoding is always utf-8, however the document spelled it. In the example, the source says UTF-8.
  • Standalone has three states: true for standalone="yes", false for standalone="no", and null when the declaration doesn’t say.
  • A missing declaration isn’t an error. XmlDocument.Declaration is null, and the document is XML 1.0.
  • XmlDocument produces this type; Utf8XmlReader reports a token. The reader reports the declaration as an XmlTokenType.XmlDeclaration token, with the version in Utf8XmlReader.Version and the pseudo-attributes, as written, in ValueSpan.
  • It’s an immutable value. In the tree that you can change, the declaration is a CloudNimble.Text.Xml.Nodes.XmlDeclarationNode.

Constructors

.ctor

Initializes a new instance of the XmlDeclarationInfo struct.

Syntax

Parameters

.ctor Inherited

Inherited from System.ValueType

Syntax

.ctor Inherited

Inherited from object

Syntax

Properties

Encoding

Gets the encoding named in the declaration.

Syntax

Property Value

Type: string The name of the encoding. This is always utf-8 for a document that XmlDocument parsed, because no other encoding is accepted.

Standalone

Gets the value of the standalone pseudo-attribute of the declaration.

Syntax

Property Value

Type: bool? true if the declaration says standalone="yes"; false if it says standalone="no"; null if the pseudo-attribute is omitted.

Version

Gets the XML version named in the declaration.

Syntax

Property Value

Type: string The version string, which is 1.0 or 1.1 for a document that XmlDocument parsed.

Methods

Equals Override

Inherited from System.ValueType

Syntax

Parameters

Returns

Type: bool

Equals Inherited Virtual

Inherited from object

Syntax

Parameters

Returns

Type: bool

Equals Inherited

Inherited from object

Syntax

Parameters

Returns

Type: bool

GetHashCode Override

Inherited from System.ValueType

Syntax

Returns

Type: int

GetHashCode Inherited Virtual

Inherited from object

Syntax

Returns

Type: int

GetType Inherited

Inherited from object

Syntax

Returns

Type: System.Type

MemberwiseClone Inherited

Inherited from object

Syntax

Returns

Type: object

ReferenceEquals Inherited

Inherited from object

Syntax

Parameters

Returns

Type: bool

ToString Override

Inherited from System.ValueType

Syntax

Returns

Type: string?

ToString Inherited Virtual

Inherited from object

Syntax

Returns

Type: string?
  • CloudNimble.Text.Xml.XmlDocument
  • CloudNimble.Text.Xml.XmlVersion
  • CloudNimble.Text.Xml.Utf8XmlReader
  • CloudNimble.Text.Xml.XmlWriterOptions
  • CloudNimble.Text.Xml.Nodes.XmlDeclarationNode