Skip to main content

XML error · prolog

Blank needed here

Two parts of the XML declaration ran together with no space between them. Terse enough to be baffling, and it always means the same thing.

Blank needed here (line 1)

What it means

The declaration's parts must be separated by whitespace: version, then encoding, then standalone. Writing version="1.0"encoding="UTF-8" leaves the parser with no boundary between them, and it says so in four words that name neither the declaration nor the missing space.

The line number is reliable here even when nothing else is: this can only happen on the first line, because that is the only place a declaration may appear.

What usually causes it

  • String-concatenating the declaration and forgetting the separator.
  • A template that emits the encoding attribute conditionally and drops the leading space with it.
  • A search-and-replace across the declaration that ate the whitespace.
  • Hand-editing the first line of a generated file.

How to fix it

  • Put a space between each part: <?xml version="1.0" encoding="UTF-8"?>.
  • Let a serializer write the declaration rather than assembling it as text.
  • If the encoding really is UTF-8, drop the attribute — it is the default and cannot then be malformed.

The same error elsewhere

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

  • Xerces (Java)

    White space is required before the "encoding" pseudo attribute in the XML declaration.
  • expat (Python)

    XML declaration not well-formed: line 1, column 20
  • .NET System.Xml

    Expected white space between attributes.

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.

Fails
<?xml version="1.0"encoding="UTF-8"?>
<root/>
Parses
<?xml version="1.0" encoding="UTF-8"?>
<root/>

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.