Skip to main content

Search 412 pages — tools, formats, elements, namespaces, directory, comparisons, XPath, datatypes, glossary, parse errors, schema errors, use cases, guides, blog and product.

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 ]]&gt; 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 &lt; and &amp; 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.

Fails
<?xml version="1.0"?>
<root><![CDATA[open
</root>
Parses
<?xml version="1.0"?>
<root><![CDATA[open]]>
</root>

Where this bites most

The terms behind it

Each of these is defined in one sentence and then demonstrated against the parser.

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.