XML error · InvalidXml
Start tag expected
There is no element at all — the input is empty, or it is not XML.
Start tag expected.What it means
The parser found no start tag anywhere. In practice the document is empty, or what arrived is not XML: an HTML error page, a JSON body, or a redirect notice served with an XML content type.
When this appears on a URL that works in a browser, the usual cause is that the server returns different content to a non-browser client — a login wall, a bot check, or a geo redirect.
What usually causes it
- An empty response body, often a 204 or a failed upstream fetch.
- An HTML error or login page returned with an XML media type.
- A JSON response from an endpoint expected to serve XML.
- A gzip-compressed body read without decompressing.
- A file that exists but was never written to.
How to fix it
- Fetch the URL with curl and look at the first bytes of the real body, not the browser's rendering.
- Check the response status and Content-Type before parsing.
- Decompress .gz sitemaps before validation.
- If a bot check is intercepting, 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.
libxml2 (PHP, lxml, Nokogiri)
Start tag expected, '<' not foundXerces (Java)
Premature end of file.expat (Python)
no element found: line 1, column 0.NET System.Xml
Root element is missing.
Before and after
Both snippets are checked on every build: the first is confirmed to produce the error above, the second to parse cleanly.
(an empty document)<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
- Expected closing tag
- Unclosed tag
- Closing tag has not been opened
- Character is not expected
- XML declaration allowed only at the start of the document
- Attribute is without value (unquoted attribute value)
- Attribute is repeated
- Attributes have open quote
- Tag is an invalid name
- Invalid tags found (open elements at end of input)
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.