# OpmlDocument

A source-preserving OPML 1.0/2.0 document with typed editing helpers.

Class 

`OfficeIMO.Opml`

**Namespace**

`OfficeIMO.Opml`

**Assembly**

`OfficeIMO.Opml`

**Source revision**

`ba882f6b0d07` with working tree changes

**Source**

[OpmlDocument.cs:55](https://github.com/EvotecIT/OfficeIMO/blob/ba882f6b0d07acddd884b5e7d3086b0cfff0a05a/OfficeIMO.Opml/OpmlDocument.cs#L55)

**Modifiers**

sealed

A source-preserving OPML 1.0/2.0 document with typed editing helpers.

## Inheritance

- object
- OpmlDocument

## Usage

Explore 5 API references to this type

This type appears in these public API surfaces even when no hand-authored example is attached directly to the page.

### Returned or exposed by 5

- Method [OpmlDocument.Create](/api/opml/officeimo-opml-opmldocument/#method-create-officeimo-opml-opmlversion)
- Method [OpmlDocument.FromOfficeDocumentModel](/api/opml/officeimo-opml-opmldocument/#method-fromofficedocumentmodel-officeimo-officedocumentmodel-nullable-officeimo-opml-opmlversion)
- Method [OpmlDocument.Load](/api/opml/officeimo-opml-opmldocument/#method-load-string-officeimo-opml-opmlloadoptions-threading-cancellationtoken)
- Method [OpmlDocument.LoadAsync](/api/opml/officeimo-opml-opmldocument/#method-loadasync-io-stream-officeimo-opml-opmlloadoptions-threading-cancellationtoken)
- Method [OpmlDocument.Parse](/api/opml/officeimo-opml-opmldocument/#method-parse-string-officeimo-opml-opmlloadoptions-threading-cancellationtoken)

Filter members 

Show inherited

## Methods

`public OpmlOutline AddOutline(string text)` [#](#method-addoutline-string)

[OpmlDocument.cs:105](https://github.com/EvotecIT/OfficeIMO/blob/ba882f6b0d07acddd884b5e7d3086b0cfff0a05a/OfficeIMO.Opml/OpmlDocument.cs#L105)

Adds a top-level outline.

Parameters

**text string required**

Returns

`OpmlOutline`

`public static OpmlDocument Create(OpmlVersion version = Opml20)` [#](#method-create-officeimo-opml-opmlversion)

[OpmlDocument.cs:55](https://github.com/EvotecIT/OfficeIMO/blob/ba882f6b0d07acddd884b5e7d3086b0cfff0a05a/OfficeIMO.Opml/OpmlDocument.cs#L55)

Creates an empty OPML document.

Parameters

**version OfficeIMO.Opml.OpmlVersion = Opml20 optional**

Returns

`OpmlDocument`

FromOfficeDocumentModel 2 overloads

`public static OpmlConversionResult<OpmlDocument> FromOfficeDocumentModel(OfficeDocumentModel model, OpmlVersion? version = null)` [#](#method-fromofficedocumentmodel-officeimo-officedocumentmodel-nullable-officeimo-opml-opmlversion)

[OpmlDocument.Conversion.cs:125](https://github.com/EvotecIT/OfficeIMO/blob/ba882f6b0d07acddd884b5e7d3086b0cfff0a05a/OfficeIMO.Opml/OpmlDocument.Conversion.cs#L125)

Creates OPML from the recursive portion of the shared document model.

Parameters

**model OfficeIMO.OfficeDocumentModel required**

**version OfficeIMO.Opml.OpmlVersion? = null optional**

Returns

`OpmlConversionResult<OpmlDocument>`

`public static OpmlConversionResult<OpmlDocument> FromOfficeDocumentModel(OfficeDocumentModel model, OpmlVersion? version, OpmlConversionOptions? options)` [#](#method-fromofficedocumentmodel-officeimo-officedocumentmodel-nullable-officeimo-opml-opmlversion-officeimo-opml-opmlconversionoptions)

[OpmlDocument.Conversion.cs:132](https://github.com/EvotecIT/OfficeIMO/blob/ba882f6b0d07acddd884b5e7d3086b0cfff0a05a/OfficeIMO.Opml/OpmlDocument.Conversion.cs#L132)

Creates OPML from the recursive portion of the shared document model with an explicit profile and bounded diagnostic budget.

Parameters

**model OfficeIMO.OfficeDocumentModel required**

**version OfficeIMO.Opml.OpmlVersion? required**

**options OfficeIMO.Opml.OpmlConversionOptions? required**

Returns

`OpmlConversionResult<OpmlDocument>`

Load 2 overloads

`public static OpmlDocument Load(string path, OpmlLoadOptions? options = null, CancellationToken cancellationToken = default)` [#](#method-load-string-officeimo-opml-opmlloadoptions-threading-cancellationtoken)

[OpmlDocument.cs:78](https://github.com/EvotecIT/OfficeIMO/blob/ba882f6b0d07acddd884b5e7d3086b0cfff0a05a/OfficeIMO.Opml/OpmlDocument.cs#L78)

Loads an OPML file.

Parameters

**path string required**

**options OfficeIMO.Opml.OpmlLoadOptions? = null optional**

**cancellationToken System.Threading.CancellationToken = default optional**

Returns

`OpmlDocument`

`public static OpmlDocument Load(Stream stream, OpmlLoadOptions? options = null, CancellationToken cancellationToken = default)` [#](#method-load-io-stream-officeimo-opml-opmlloadoptions-threading-cancellationtoken)

[OpmlDocument.cs:88](https://github.com/EvotecIT/OfficeIMO/blob/ba882f6b0d07acddd884b5e7d3086b0cfff0a05a/OfficeIMO.Opml/OpmlDocument.cs#L88)

Loads OPML from a caller-owned stream without changing a seekable stream's position.

Parameters

**stream System.IO.Stream required**

**options OfficeIMO.Opml.OpmlLoadOptions? = null optional**

**cancellationToken System.Threading.CancellationToken = default optional**

Returns

`OpmlDocument`

`public static async Task<OpmlDocument> LoadAsync(Stream stream, OpmlLoadOptions? options = null, CancellationToken cancellationToken = default)` [#](#method-loadasync-io-stream-officeimo-opml-opmlloadoptions-threading-cancellationtoken)

Loads OPML asynchronously from a caller-owned stream.

Parameters

**stream System.IO.Stream required**

**options OfficeIMO.Opml.OpmlLoadOptions? = null optional**

**cancellationToken System.Threading.CancellationToken = default optional**

Returns

`Task<OpmlDocument>`

`public static OpmlDocument Parse(string text, OpmlLoadOptions? options = null, CancellationToken cancellationToken = default)` [#](#method-parse-string-officeimo-opml-opmlloadoptions-threading-cancellationtoken)

[OpmlDocument.cs:66](https://github.com/EvotecIT/OfficeIMO/blob/ba882f6b0d07acddd884b5e7d3086b0cfff0a05a/OfficeIMO.Opml/OpmlDocument.cs#L66)

Parses OPML text with secure, bounded XML settings.

Parameters

**text string required**

**options OfficeIMO.Opml.OpmlLoadOptions? = null optional**

**cancellationToken System.Threading.CancellationToken = default optional**

Returns

`OpmlDocument`

Save 3 overloads

`public void Save(Stream destination, OpmlSaveOptions? options = null)` [#](#method-save-io-stream-officeimo-opml-opmlsaveoptions)

[OpmlDocument.cs:247](https://github.com/EvotecIT/OfficeIMO/blob/ba882f6b0d07acddd884b5e7d3086b0cfff0a05a/OfficeIMO.Opml/OpmlDocument.cs#L247)

Writes OPML to a caller-owned stream and rewinds a seekable destination.

Parameters

**destination System.IO.Stream required**

**options OfficeIMO.Opml.OpmlSaveOptions? = null optional**

`public void Save(OpmlSaveOptions? options = null)` [#](#method-save-officeimo-opml-opmlsaveoptions)

[OpmlDocument.cs:255](https://github.com/EvotecIT/OfficeIMO/blob/ba882f6b0d07acddd884b5e7d3086b0cfff0a05a/OfficeIMO.Opml/OpmlDocument.cs#L255)

Saves to the associated path, failing when no destination is associated.

Parameters

**options OfficeIMO.Opml.OpmlSaveOptions? = null optional**

`public void Save(string path, OpmlSaveOptions? options = null)` [#](#method-save-string-officeimo-opml-opmlsaveoptions)

[OpmlDocument.cs:259](https://github.com/EvotecIT/OfficeIMO/blob/ba882f6b0d07acddd884b5e7d3086b0cfff0a05a/OfficeIMO.Opml/OpmlDocument.cs#L259)

Atomically saves native output and associates the successfully written path.

Parameters

**path string required**

**options OfficeIMO.Opml.OpmlSaveOptions? = null optional**

SaveAsync 3 overloads

`public Task SaveAsync(Stream destination, OpmlSaveOptions? options = null, CancellationToken cancellationToken = default)` [#](#method-saveasync-io-stream-officeimo-opml-opmlsaveoptions-threading-cancellationtoken)

[OpmlDocument.cs:251](https://github.com/EvotecIT/OfficeIMO/blob/ba882f6b0d07acddd884b5e7d3086b0cfff0a05a/OfficeIMO.Opml/OpmlDocument.cs#L251)

Writes OPML asynchronously to a caller-owned stream.

Parameters

**destination System.IO.Stream required**

**options OfficeIMO.Opml.OpmlSaveOptions? = null optional**

**cancellationToken System.Threading.CancellationToken = default optional**

Returns

`Task`

`public Task SaveAsync(OpmlSaveOptions? options = null, CancellationToken cancellationToken = default)` [#](#method-saveasync-officeimo-opml-opmlsaveoptions-threading-cancellationtoken)

[OpmlDocument.cs:266](https://github.com/EvotecIT/OfficeIMO/blob/ba882f6b0d07acddd884b5e7d3086b0cfff0a05a/OfficeIMO.Opml/OpmlDocument.cs#L266)

Asynchronously saves to the associated path.

Parameters

**options OfficeIMO.Opml.OpmlSaveOptions? = null optional**

**cancellationToken System.Threading.CancellationToken = default optional**

Returns

`Task`

`public async Task SaveAsync(string path, OpmlSaveOptions? options = null, CancellationToken cancellationToken = default)` [#](#method-saveasync-string-officeimo-opml-opmlsaveoptions-threading-cancellationtoken)

Atomically saves native output asynchronously and associates the successfully written path.

Parameters

**path string required**

**options OfficeIMO.Opml.OpmlSaveOptions? = null optional**

**cancellationToken System.Threading.CancellationToken = default optional**

Returns

`Task`

`public byte[] ToBytes(OpmlSaveOptions? options = null)` [#](#method-tobytes-officeimo-opml-opmlsaveoptions)

[OpmlDocument.cs:283](https://github.com/EvotecIT/OfficeIMO/blob/ba882f6b0d07acddd884b5e7d3086b0cfff0a05a/OfficeIMO.Opml/OpmlDocument.cs#L283)

Serializes native bytes, preserving an unchanged source when requested.

Parameters

**options OfficeIMO.Opml.OpmlSaveOptions? = null optional**

Returns

`byte[]`

ToOfficeDocumentModel 3 overloads

`public OpmlConversionResult<OfficeDocumentModel> ToOfficeDocumentModel(string? sourcePath = null)` [#](#method-toofficedocumentmodel-string)

[OpmlDocument.Conversion.cs:12](https://github.com/EvotecIT/OfficeIMO/blob/ba882f6b0d07acddd884b5e7d3086b0cfff0a05a/OfficeIMO.Opml/OpmlDocument.Conversion.cs#L12)

Converts this document to the shared recursive document model.

Parameters

**sourcePath string? = null optional**

Returns

`OpmlConversionResult<OfficeDocumentModel>`

`public OpmlConversionResult<OfficeDocumentModel> ToOfficeDocumentModel(string? sourcePath, OpmlConversionOptions? options)` [#](#method-toofficedocumentmodel-string-officeimo-opml-opmlconversionoptions)

[OpmlDocument.Conversion.cs:17](https://github.com/EvotecIT/OfficeIMO/blob/ba882f6b0d07acddd884b5e7d3086b0cfff0a05a/OfficeIMO.Opml/OpmlDocument.Conversion.cs#L17)

Converts this document to the shared recursive document model with a source path and bounded diagnostic budget.

Parameters

**sourcePath string? required**

**options OfficeIMO.Opml.OpmlConversionOptions? required**

Returns

`OpmlConversionResult<OfficeDocumentModel>`

`public OpmlConversionResult<OfficeDocumentModel> ToOfficeDocumentModel(string? sourcePath, OpmlConversionOptions? options, CancellationToken cancellationToken)` [#](#method-toofficedocumentmodel-string-officeimo-opml-opmlconversionoptions-threading-cancellationtoken)

[OpmlDocument.Conversion.cs:24](https://github.com/EvotecIT/OfficeIMO/blob/ba882f6b0d07acddd884b5e7d3086b0cfff0a05a/OfficeIMO.Opml/OpmlDocument.Conversion.cs#L24)

Converts this document to the shared recursive document model with bounded diagnostics and cancellation.

Parameters

**sourcePath string? required**

**options OfficeIMO.Opml.OpmlConversionOptions? required**

**cancellationToken System.Threading.CancellationToken required**

Returns

`OpmlConversionResult<OfficeDocumentModel>`

`public string ToOpml(OpmlSaveOptions? options = null)` [#](#method-toopml-officeimo-opml-opmlsaveoptions)

[OpmlDocument.cs:237](https://github.com/EvotecIT/OfficeIMO/blob/ba882f6b0d07acddd884b5e7d3086b0cfff0a05a/OfficeIMO.Opml/OpmlDocument.cs#L237)

Returns OPML text, preserving the exact input while unchanged by default.

Parameters

**options OfficeIMO.Opml.OpmlSaveOptions? = null optional**

Returns

`string`

Validate 4 overloads

`public OpmlValidationResult Validate()` [#](#method-validate)

[OpmlDocument.cs:112](https://github.com/EvotecIT/OfficeIMO/blob/ba882f6b0d07acddd884b5e7d3086b0cfff0a05a/OfficeIMO.Opml/OpmlDocument.cs#L112)

Validates the supported OPML profile without discarding extension content.

Returns

`OpmlValidationResult`

`public OpmlValidationResult Validate(CancellationToken cancellationToken)` [#](#method-validate-threading-cancellationtoken)

[OpmlDocument.cs:115](https://github.com/EvotecIT/OfficeIMO/blob/ba882f6b0d07acddd884b5e7d3086b0cfff0a05a/OfficeIMO.Opml/OpmlDocument.cs#L115)

Validates the supported OPML profile while observing cancellation during semantic walks.

Parameters

**cancellationToken System.Threading.CancellationToken required**

Returns

`OpmlValidationResult`

`public OpmlValidationResult Validate(OpmlValidationOptions? options)` [#](#method-validate-officeimo-opml-opmlvalidationoptions)

[OpmlDocument.cs:118](https://github.com/EvotecIT/OfficeIMO/blob/ba882f6b0d07acddd884b5e7d3086b0cfff0a05a/OfficeIMO.Opml/OpmlDocument.cs#L118)

Validates the supported OPML profile with a bounded diagnostic budget.

Parameters

**options OfficeIMO.Opml.OpmlValidationOptions? required**

Returns

`OpmlValidationResult`

`public OpmlValidationResult Validate(OpmlValidationOptions? options, CancellationToken cancellationToken)` [#](#method-validate-officeimo-opml-opmlvalidationoptions-threading-cancellationtoken)

[OpmlDocument.cs:122](https://github.com/EvotecIT/OfficeIMO/blob/ba882f6b0d07acddd884b5e7d3086b0cfff0a05a/OfficeIMO.Opml/OpmlDocument.cs#L122)

Validates the supported OPML profile with a bounded diagnostic budget and cancellation.

Parameters

**options OfficeIMO.Opml.OpmlValidationOptions? required**

**cancellationToken System.Threading.CancellationToken required**

Returns

`OpmlValidationResult`

## Inherited Methods

`public virtual bool Equals(object? obj)` [#](#method-equals-object)

Inherited from object

Parameters

**obj object? required**

Returns

`bool`

`public virtual int GetHashCode()` [#](#method-gethashcode)

Inherited from object

Returns

`int`

`public Type GetType()` [#](#method-gettype)

Inherited from object

Returns

`Type`

`public virtual string? ToString()` [#](#method-tostring)

Inherited from object

Returns

`string?`

## Properties

`public string? FilePath { get; }` [#](#property-filepath)

[OpmlDocument.cs:12](https://github.com/EvotecIT/OfficeIMO/blob/ba882f6b0d07acddd884b5e7d3086b0cfff0a05a/OfficeIMO.Opml/OpmlDocument.cs#L12)

Gets the associated path, or null for an in-memory document.

`public string DeclaredVersion { get; set; }` [#](#property-declaredversion)

[OpmlDocument.cs:29](https://github.com/EvotecIT/OfficeIMO/blob/ba882f6b0d07acddd884b5e7d3086b0cfff0a05a/OfficeIMO.Opml/OpmlDocument.cs#L29)

The declared OPML version text, including a preserved 1.1 declaration.

`public OpmlVersion Version { get; }` [#](#property-version)

[OpmlDocument.cs:37](https://github.com/EvotecIT/OfficeIMO/blob/ba882f6b0d07acddd884b5e7d3086b0cfff0a05a/OfficeIMO.Opml/OpmlDocument.cs#L37)

The effective supported OPML profile.

`public bool IsModified { get; }` [#](#property-ismodified)

[OpmlDocument.cs:39](https://github.com/EvotecIT/OfficeIMO/blob/ba882f6b0d07acddd884b5e7d3086b0cfff0a05a/OfficeIMO.Opml/OpmlDocument.cs#L39)

True after a typed or extension mutation.

`public OpmlHead Head { get; }` [#](#property-head)

[OpmlDocument.cs:41](https://github.com/EvotecIT/OfficeIMO/blob/ba882f6b0d07acddd884b5e7d3086b0cfff0a05a/OfficeIMO.Opml/OpmlDocument.cs#L41)

Typed standard head values.

`public IReadOnlyList<OpmlOutline> Outlines { get; }` [#](#property-outlines)

[OpmlDocument.cs:43](https://github.com/EvotecIT/OfficeIMO/blob/ba882f6b0d07acddd884b5e7d3086b0cfff0a05a/OfficeIMO.Opml/OpmlDocument.cs#L43)

Top-level outlines in document order.

`public XDocument Xml { get; }` [#](#property-xml)

[OpmlDocument.cs:45](https://github.com/EvotecIT/OfficeIMO/blob/ba882f6b0d07acddd884b5e7d3086b0cfff0a05a/OfficeIMO.Opml/OpmlDocument.cs#L45)

Underlying XML for advanced lossless extension inspection.

<!-- PowerForge markdown artifact sha256:33B9849ED3C2C7E7142EE0072058389FB3BE0351D8AD6B2913953136D90029D7 -->
