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 |
|---|---|
| Specification | RSS 1.0 Specification |
| Namespaces | Atom, Dublin Core, Dublin Core Terms, Syndication, Content, Slash, Media RSS, Comment API, Administrative, GeoRSS Simple, RDF, XML |
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'
// 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<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
},
TStrict
>
export type TextInput<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
},
TStrict
>
export type Item<TDate extends DateLike, 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>
content?: ContentNs.Item
slash?: SlashNs.Item
media?: MediaNs.ItemOrFeed<TStrict>
georss?: GeoRssNs.ItemOrFeed<TStrict>
dcterms?: DcTermsNs.ItemOrFeed<TDate>
wfw?: WfwNs.Item
xml?: XmlNs.ItemOrFeed
},
TStrict
>
export type Feed<TDate extends DateLike, 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<TStrict>
items?: Array<Item<TDate, TStrict>>
textInput?: TextInput<TStrict>
rdf?: RdfNs.About
atom?: AtomNs.Feed<TDate>
dc?: DcNs.ItemOrFeed<TDate>
sy?: SyNs.Feed<TDate>
media?: MediaNs.ItemOrFeed<TStrict>
georss?: GeoRssNs.ItemOrFeed<TStrict>
dcterms?: DcTermsNs.ItemOrFeed<TDate>
admin?: AdminNs.Feed
xml?: XmlNs.ItemOrFeed
},
TStrict
>
}Related
- Parsing RDF Feeds - How to parse RDF content
- RDF Detection - Detecting RDF format