Skip to content

Expose xml:lang on Atom feeds #286

Description

@tunniclm

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions