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.
| Versions | 0.9, 1.0 |
|---|---|
| Namespaces | Atom, 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.
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
| Parameter | Type | Description |
|---|---|---|
content | string | The RDF XML content to parse |
options | object | Optional parsing settings |
Options
| Option | Type | Default | Description |
|---|---|---|---|
maxItems | number | - | 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
| Parameter | Type | Description |
|---|---|---|
content | string | The content to check |
Returns
boolean - true if content appears to be RDF format
Example
import { detectRdfFeed } from 'feedsmith'
const isRdf = detectRdfFeed(xmlContent)Types
All RDF types are available under the Rdf namespace:
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 typesSee 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.
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
}
}Related
- Parsing RDF Feeds - How to parse RDF content
- RDF Detection - Detecting RDF format