XML error · syntax
Document is empty
Nothing arrived at all. Almost always a transport problem — a 204, a dropped connection, or a fetch that succeeded against the wrong URL.
Document is empty (line 1)What it means
The parser was handed zero bytes. This is distinct from "Start tag expected", which means something arrived but was not XML; here there was no content whatsoever.
Because the failure is upstream of the document, nothing about the XML itself is at fault. Reading the document will never explain it — the answer is in the response that produced it.
What usually causes it
- An HTTP 204, a 304 handled as a 200, or a body consumed twice before parsing.
- A feed or sitemap endpoint that returns an empty body when it has nothing to publish.
- A file written but never flushed, or read before the writer closed it.
- A gzip-encoded response decoded with the wrong content encoding, yielding nothing.
- A conditional request answered with an empty body because an ETag matched.
How to fix it
- Log the status code and Content-Length alongside the body before parsing, so the empty case is visible.
- Treat an empty body as its own outcome rather than as a parse failure — they need different alerts.
- Check the response was not already read: a stream consumed once is empty the second time.
- For scheduled fetches, retry once; an empty body is frequently transient.
The same error elsewhere
Different parsers, same defect. If you arrived with one of these messages, you are in the right place.
Xerces (Java)
Premature end of file.expat (Python)
no element found: line 1, column 0Go encoding/xml
EOF.NET System.Xml
Root element is missing.
Before and after
Both snippets are re-checked by the test suite against the real parser: the first is confirmed to produce the exact error above, the second to parse cleanly.
(an empty document)<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url><loc>https://example.com/</loc></url>
</urlset>Where this bites most
Other XML errors
- Opening and ending tag mismatch
- Premature end of data in tag
- Extra content at the end of the document
- Unescaped ampersand (EntityRef: expecting ';')
- Entity is not defined
- Start tag expected
- XML declaration allowed only at the start of the document
- Unquoted attribute value (AttValue expected)
- Attribute redefined
- Attributes construct error (unterminated quote)
- Invalid element name
- Unsupported encoding
- Sequence ']]>' not allowed in content
- Comment not terminated
- Detected an entity reference loop
- PCDATA invalid Char value (control character)
- Unescaped '<' in an attribute value
- Invalid numeric character reference
- Blank needed here
- Malformed declaration expecting version
- Unsupported XML version
- Processing instruction not terminated
- CData section not finished
- Error parsing attribute name
- Double hyphen within comment
- CharRef: invalid decimal value
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.