OPML Reference
OPML (Outline Processor Markup Language) is a format for exchanging outline-structured information, commonly used for sharing feed subscription lists.
Versions | 1.0, 2.0 |
---|
Functions
parseOpml()
Parses OPML content and returns a typed OPML object.
typescript
import { parseOpml } from 'feedsmith'
const opml = parseOpml(xmlContent, {
extraOutlineAttributes: ['customIcon', 'updateInterval']
})
// Returns: object with all fields optional and dates as strings
Parameters
Parameter | Type | Description |
---|---|---|
content | string | The OPML XML content to parse |
options | object | Optional parsing settings |
Options
Option | Type | Default | Description |
---|---|---|---|
extraOutlineAttributes | string[] | - | Custom attributes to extract from outline elements (case-insensitive), see examples |
Returns
object
- Parsed OPML with all fields optional and dates as strings
generateOpml()
Generates OPML XML from OPML data.
typescript
import { generateOpml } from 'feedsmith'
const xml = generateOpml(opmlData, {
lenient: true,
stylesheets: [{ type: 'text/xsl', href: '/opml.xsl' }],
extraOutlineAttributes: ['customIcon', 'updateInterval']
})
Parameters
Parameter | Type | Description |
---|---|---|
data | object | OPML data to generate |
options | object | Optional generation settings |
Options
Option | Type | Default | Description |
---|---|---|---|
lenient | boolean | false | Enable lenient mode for relaxed validation, see Lenient Mode |
stylesheets | Stylesheet[] | - | Add stylesheets for visual formatting, see Feed Styling |
extraOutlineAttributes | string[] | - | Custom attributes to include in outline elements. Only specified attributes are included in generated XML, see examples |
Returns
string
- Generated OPML XML
Types
INFO
TDate
represents date fields in the type definitions. When parsing, dates are returned as strings in their original format (see Parsing › Handling Dates for more details). When generating, dates should be provided as JavaScript Date
objects.
ts
export type Outline<
TDate extends DateLike,
A extends ReadonlyArray<string> = ReadonlyArray<string>,
> = {
text: string
type?: string
isComment?: boolean
isBreakpoint?: boolean
created?: TDate
category?: string
description?: string
xmlUrl?: string
htmlUrl?: string
language?: string
title?: string
version?: string
url?: string
outlines?: Array<Outline<TDate, A>>
} & ExtraFields<A>
export type Head<TDate extends DateLike> = {
title?: string
dateCreated?: TDate
dateModified?: TDate
ownerName?: string
ownerEmail?: string
ownerId?: string
docs?: string
expansionState?: Array<number>
vertScrollState?: number
windowTop?: number
windowLeft?: number
windowBottom?: number
windowRight?: number
}
export type Body<
TDate extends DateLike,
A extends ReadonlyArray<string> = ReadonlyArray<string>,
> = {
outlines?: Array<Outline<TDate, A>>
}
export type Opml<
TDate extends DateLike,
A extends ReadonlyArray<string> = ReadonlyArray<string>,
> = {
head?: Head<TDate>
body?: Body<TDate, A>
}
INFO
The Outline
type includes an index signature [key: string]: unknown
which allows storing any custom attributes alongside the standard OPML properties.