XML error · syntax
Processing instruction not terminated
A processing instruction was opened with <? and never closed with ?>. Everything after it is consumed as instruction data until the file runs out.
ParsePI: PI target never end ... (line 2)What it means
A processing instruction carries a target and data to an application — <?xml-stylesheet …?> is the one most people meet. It ends at ?>, and until the parser sees that it treats every following byte as part of the instruction.
The trailing ellipsis in libxml2's message is not truncation on our side; the parser prints it because the instruction it was reading never came to an end.
What usually causes it
- A stylesheet instruction closed with > rather than ?>.
- A templating language whose own <? … ?> delimiters were emitted into the output instead of being executed.
- PHP short tags landing in an XML response.
- Hand-editing a processing instruction and removing the question mark.
How to fix it
- Close it with ?> — the question mark is part of the terminator, not decoration.
- Check the document for stray <? sequences that were never meant to be instructions.
- If a template engine shares the delimiter, escape it or switch the engine's delimiters.
The same error elsewhere
Different parsers, same defect. If you arrived with one of these messages, you are in the right place.
Xerces (Java)
The processing instruction must end with "?>".expat (Python)
unclosed token: line 2, column 6.NET System.Xml
Unexpected end of file has occurred.
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"?>
<root><?target data</root><?xml version="1.0"?>
<root><?target data?></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
- Blank needed here
- Malformed declaration expecting version
- Unsupported XML version
- 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.