Magpie HTML - v0.1.3
    Preparing search index...

    Function parseFeed

    • Parse any feed format with automatic format detection.

      Parameters

      • content: string

        Feed content as string (XML or JSON)

      • OptionalbaseUrl: string | URL

        Optional base URL for resolving relative URLs (string or URL object)

      Returns ParseResult

      Object containing normalized feed data and original format-specific data

      This is the main entry point for feed parsing. It automatically detects whether the content is RSS, Atom, or JSON Feed, parses it, and returns a normalized output structure along with the original format-specific data.

      All relative URLs in the feed are converted to absolute URLs if a base URL is provided. This is essential for feed readers that need to fetch images, enclosures, or follow links.

      Error if format cannot be detected or parsing fails

      const feedContent = await fetch('https://example.com/feed.xml').then(r => r.text());
      const result = parseFeed(feedContent, 'https://example.com/feed.xml');

      console.log(result.feed.title);
      console.log(result.feed.items[0].title);
      console.log(result.feed.items[0].url); // Absolute URL