Skip to content

RDF Feed Reference

RDF (Resource Description Framework) Site Summary is an early XML-based syndication format that uses RDF metadata. Feedsmith provides full parsing capabilities.

Versions0.9, 1.0
NamespacesAtom, Dublin Core, Syndication, Content, Slash, Media RSS, GeoRSS Simple, Dublin Core Terms, Comment API, Administrative

Functions

parseRdfFeed()

Parses RDF feed content and returns a typed RDF object.

typescript
import { parseRdfFeed } from 'feedsmith'

const rdfFeed = parseRdfFeed(xmlContent)
// Returns: object with all fields optional and dates as strings

// Limit number of items parsed
const rdfFeed = parseRdfFeed(xmlContent, { maxItems: 10 })

Parameters

ParameterTypeDescription
contentstringThe RDF XML content to parse
optionsobjectOptional parsing settings

Options

OptionTypeDefaultDescription
maxItemsnumber-Limit the number of items parsed. Use 0 to skip items entirely, useful when only feed metadata is needed

Returns

object - Parsed RDF feed with all fields optional and dates as strings

generateRdfFeed()

NOTE

RDF feed generation is planned but not yet available.

detectRdfFeed()

Detects if the provided content is an RDF feed.

Parameters

ParameterTypeDescription
contentstringThe content to check

Returns

boolean - true if content appears to be RDF format

Example

typescript
import { detectRdfFeed } from 'feedsmith'

const isRdf = detectRdfFeed(xmlContent)

Types

All RDF types are available under the Rdf namespace:

typescript
import type { Rdf } from 'feedsmith/types'

// Access any type from the definitions below
type Feed = Rdf.Feed<Date>
type Item = Rdf.Item<Date>
type Image = Rdf.Image
type TextInput = Rdf.TextInput
// … see type definitions below for all available types

See the TypeScript guide for usage examples.

Type Definitions

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 namespace Rdf {
  export type Image = {
    title: string
    link: string
    url?: string
  }

  export type TextInput = {
    title: string
    description: string
    name: string
    link: string
  }

  export type Item<TDate extends DateLike> = {
    title: string
    link: string
    description?: string
    atom?: AtomNs.Entry<TDate>
    dc?: DcNs.ItemOrFeed<TDate>
    content?: ContentNs.Item
    slash?: SlashNs.Item
    media?: MediaNs.ItemOrFeed
    georss?: GeoRssNs.ItemOrFeed
    dcterms?: DcTermsNs.ItemOrFeed<TDate>
    wfw?: WfwNs.Item
  }

  export type Feed<TDate extends DateLike> = {
    title: string
    link: string
    description: string
    image?: Image
    items?: Array<Item<TDate>>
    textInput?: TextInput
    atom?: AtomNs.Feed<TDate>
    dc?: DcNs.ItemOrFeed<TDate>
    sy?: SyNs.Feed<TDate>
    media?: MediaNs.ItemOrFeed
    georss?: GeoRssNs.ItemOrFeed
    dcterms?: DcTermsNs.ItemOrFeed<TDate>
    admin?: AdminNs.Feed
  }
}