Skip to main content
XMLDir

Search 309 pages — tools, formats, elements, namespaces, directory, comparisons, XPath, datatypes, glossary, parse errors, schema errors, use cases, blog and product.

RSS 2.0

<enclosure>

The media file attached to an item — the element podcasting is built on, and the one whose length attribute is routinely wrong.

An enclosure is an empty element with three required attributes: url, length in bytes, and MIME type. It is how a podcast episode's audio file is attached to its item, and every podcast client reads it.

length is the file size in bytes, and it is required. Emitting 0, or a stale value from before re-encoding, breaks progress bars and seeking in several clients — a failure that never surfaces as a feed error.

Format
RSS 2.0
Namespace
None — RSS elements are unqualified
Parent
<item>
How many
At most one per <item>.

What it contains

Nothing — this element holds a value rather than other elements. Its content is text, and the constraints below are what that text has to be.

Attributes

  • urlrequiredAbsolute URL of the media file.
  • lengthrequiredSize in bytes. 0 is accepted by feeds and breaks clients.
  • typerequiredMIME type, e.g. audio/mpeg.

Cardinality and constraints

At most one per <item>.

  • url, length and type are all required attributes.
  • length is the size in bytes, not a duration.
  • Always an empty element — an enclosure has no content.

What our validator does

We do not check enclosures — the attributes are not read, so a missing length or a zero one passes silently.

We do not catch this one

length="0" says the audio file is empty. Clients that trust it show a zero-length episode and cannot seek within it, and our feed checks do not read enclosure attributes at all — the two documents below produce the same verdict.

Broken and fixed

Both documents below are well-formed XML — that is the point of this corpus — and both are run through the validator on every test run. The verdicts here are what it returned, not what we expect it to.

broken
<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <title>Example</title>
    <link>https://example.com/</link>
    <description>Notes from the example farm.</description>
    <item>
      <title>Episode 1</title>
      <guid>https://example.com/ep1</guid>
      <enclosure url="https://example.com/ep1.mp3" length="0" type="audio/mpeg"/>
    </item>
  </channel>
</rss>
No issue reported. This defect passes our checks.
fixed
<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <title>Example</title>
    <link>https://example.com/</link>
    <description>Notes from the example farm.</description>
    <item>
      <title>Episode 1</title>
      <guid>https://example.com/ep1</guid>
      <enclosure url="https://example.com/ep1.mp3" length="24576000" type="audio/mpeg"/>
    </item>
  </channel>
</rss>
No errors. Warnings may remain — a conforming feed can still be missing a self link — but nothing here is wrong.

Get started

Bring order to the XML your team can't afford to ignore.

Create a free account and get a private workspace to search, validate, diff, and monitor your XML feeds, sitemaps, schemas, and vendor integrations.