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.
<?xml version="1.0"encoding="UTF-8"?>
<root/><?xml version="1.0" encoding="UTF-8"?>
<root/>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
- 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
- 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.