Skip to main content

XML error · InvalidXml

Invalid tags found (open elements at end of input)

The input ended with several elements still open; the validator lists the whole open stack.

Invalid '[ "urlset", "url"]' found.

What it means

This is the multi-element form of an unclosed tag: rather than one element left open, the parser ran out of input with a stack of them, and reports the stack contents as a list.

It almost always means truncation rather than an authoring mistake — a document written correctly does not usually lose several closing tags at once.

What usually causes it

  • A truncated file or a response cut short mid-stream.
  • A generator that crashed partway through writing nested output.
  • A gzip stream that ended prematurely and decompressed partially.
  • A size limit applied at a proxy, silently clipping a large sitemap or feed.

How to fix it

  • Compare the received byte count with the source's; the listed stack tells you how deep the cut was.
  • Re-fetch, and check for proxy or gateway response-size limits on large documents.
  • Write generated XML atomically: build the whole document, then publish it.

The same error elsewhere

Different parsers, same defect. If you arrived with one of these messages, you are in the right place.

  • libxml2 (PHP, lxml, Nokogiri)

    Premature end of data in tag url line 2
  • Xerces (Java)

    XML document structures must start and end within the same entity.
  • Go encoding/xml

    unexpected EOF

Before and after

Both snippets are checked on every build: the first is confirmed to produce the error above, the second to parse cleanly.

Fails
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
  <url>
    <loc>https://example.com/</loc>
Parses
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
  <url>
    <loc>https://example.com/</loc>
  </url>
</urlset>

Where this bites most

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.