XML error · syntax
CData section not finished
A CDATA section was opened and never closed with ]]>, so the rest of the document — closing tags included — was read as literal text inside it.
CData section not finished (line 3)What it means
Inside <![CDATA[ … ]]> nothing is markup: angle brackets, ampersands and tags are all just characters. That is the point, and it is also why an unclosed section is so destructive — every remaining tag in the file is swallowed as text.
The reported line is where the document ended, not where the section opened. Search backwards for the last <![CDATA[ without a matching ]]>.
What usually causes it
- Writing ]] > or ]]> instead of the literal ]]> terminator.
- Content that itself contained ]]>, terminating the section early and leaving a second, unclosed one.
- A generator that writes the opener and the closer on separate code paths, one of which can be skipped.
- Truncation partway through a large CDATA block, which is common on HTML-heavy feed items.
How to fix it
- Close the section with exactly ]]> — three characters, no spaces.
- Scan the wrapped content for ]]> before wrapping it, and split the section if it appears.
- Consider not using CDATA at all: escaping < and & normally is always safe and never has a terminator to lose.
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 CDATA section must end with "]]>".expat (Python)
unclosed CDATA section: line 2, column 6.NET System.Xml
Unexpected end of file while parsing CDATA 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><![CDATA[open
</root><?xml version="1.0"?>
<root><![CDATA[open]]>
</root>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
- Processing instruction not terminated
- 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.