XML error · syntax
Start tag expected
What arrived is not XML — an HTML error page, a JSON body, or plain text served under an XML content type. The parser found no opening tag.
Start tag expected, '<' not found (line 1)What it means
The parser found no start tag where the document should begin, because the content does not start with "<" at all. In practice the response is not XML: a JSON body, a plain-text error, or a stack trace served with an XML content type. An entirely empty body reports "Document is empty" instead.
When this appears for a URL that works in a browser, the usual cause is that the server returns something different to a non-browser client — a bot check, a login wall, or a geo redirect.
Worth knowing what does not land here: a tidy HTML error page is frequently well-formed XML. It parses cleanly and then fails on its root element being <html> rather than what you expected, which is a different problem with a different fix.
What usually causes it
- A JSON response from an endpoint expected to serve XML.
- A plain-text error or stack trace returned with an XML media type.
- A bot-protection challenge served to anything without browser headers.
- A gzip-compressed body read without decompressing.
- An empty response body — reported as "Document is empty".
How to fix it
- Fetch with curl and look at the first bytes of the real body, not the browser's rendering.
- Check the status code and Content-Type before parsing.
- Decompress .gz sitemaps before validation.
- If a bot check intercepts, allowlist the crawler or fetch server-side.
The same error elsewhere
Different parsers, same defect. If you arrived with one of these messages, you are in the right place.
Xerces (Java)
Content is not allowed in prolog.expat (Python)
syntax error: line 1, column 0.NET System.Xml
Data at the root level is invalid. Line 1, position 1.Go encoding/xml
expected element type <urlset> but have <html>
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.
{"error":"not_found","status":404}<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
- 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
- Document is empty
- 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.