rss-parser icon indicating copy to clipboard operation
rss-parser copied to clipboard

Expose xml:lang on Atom feeds

Open tunniclm opened this issue 6 months ago • 0 comments

Some Atom feeds only define their language via the root <feed> element using the xml:lang attribute.

It would be great if it were possible to access this value as a fallback in cases where there is no <language> or <dc:language> element provided in the feed.

Example:

<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="it-IT">
...

Workaround:

I have been able to work around this by specifying the following configuration:

const parser = new Parser({
    customFields: {
        feed: [['$', 'feedRoot', { keepArray: true }]]
    }
});
const parsedFeed = await parser.parseString(feedXML);
const fallbackLanguage = parsedFeed.feedRoot?.['xml:lang'];

The fact this works seems accidental rather than intentional, so I'd prefer a more official solution.

tunniclm avatar Jul 04 '25 10:07 tunniclm