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
SpecificationRSS 1.0 Specification
NamespacesAtom, Dublin Core, Dublin Core Terms, Syndication, Content, Slash, Media RSS, FeedBurner, OpenSearch, PRISM, ccREL, Comment API, Administrative, Pingback, Trackback, W3C Basic Geo, GeoRSS Simple, RDF, XML

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 RdfFeed namespace:

typescript
import type { RdfFeed } from 'feedsmith'

// Access any type from the definitions below
type Feed = RdfFeed.Feed<Date>
type Item = RdfFeed.Item<Date>
type Image = RdfFeed.Image<Date>
type TextInput = RdfFeed.TextInput<Date>
// … 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 RdfFeed {
  export type Image<TDate, TStrict extends boolean = false> = Strict<
    {
      title: Requirable<string> // Required in spec
      link: Requirable<string> // Required in spec
      url: Requirable<string> // Required in spec
      rdf?: RdfNs.About
      prism?: PrismNs.ItemOrFeed<TDate>
      cc?: CcNs.ItemOrFeed
    },
    TStrict
  >

  export type TextInput<TDate, TStrict extends boolean = false> = Strict<
    {
      title: Requirable<string> // Required in spec
      description: Requirable<string> // Required in spec
      name: Requirable<string> // Required in spec
      link: Requirable<string> // Required in spec
      rdf?: RdfNs.About
      prism?: PrismNs.ItemOrFeed<TDate>
    },
    TStrict
  >

  export type Item<TDate, TStrict extends boolean = false> = Strict<
    {
      title: Requirable<string> // Required in spec
      link: Requirable<string> // Required in spec
      description?: string
      rdf?: RdfNs.About
      atom?: AtomNs.Entry<TDate>
      dc?: DcNs.ItemOrFeed<TDate>
      dcterms?: DcTermsNs.ItemOrFeed<TDate>
      content?: ContentNs.Item
      slash?: SlashNs.Item
      media?: MediaNs.ItemOrFeed<TStrict>
      feedburner?: FeedBurnerNs.Item
      prism?: PrismNs.ItemOrFeed<TDate>
      cc?: CcNs.ItemOrFeed
      wfw?: WfwNs.Item
      pingback?: PingbackNs.Item
      trackback?: TrackbackNs.Item
      geo?: GeoNs.ItemOrFeed
      georss?: GeoRssNs.ItemOrFeed<TStrict>
      xml?: XmlNs.ItemOrFeed
    },
    TStrict
  >

  export type Feed<TDate, TStrict extends boolean = false> = Strict<
    {
      title: Requirable<string> // Required in spec
      link: Requirable<string> // Required in spec
      description: Requirable<string> // Required in spec
      image?: Image<TDate, TStrict>
      items?: Array<Item<TDate, TStrict>>
      textInput?: TextInput<TDate, TStrict>
      rdf?: RdfNs.About
      atom?: AtomNs.Feed<TDate>
      dc?: DcNs.ItemOrFeed<TDate>
      dcterms?: DcTermsNs.ItemOrFeed<TDate>
      sy?: SyNs.Feed<TDate>
      media?: MediaNs.ItemOrFeed<TStrict>
      feedburner?: FeedBurnerNs.Feed<TStrict>
      opensearch?: OpenSearchNs.Feed<TStrict>
      prism?: PrismNs.ItemOrFeed<TDate>
      cc?: CcNs.ItemOrFeed
      admin?: AdminNs.Feed
      geo?: GeoNs.ItemOrFeed
      georss?: GeoRssNs.ItemOrFeed<TStrict>
      xml?: XmlNs.ItemOrFeed
    },
    TStrict
  >
}