XML error · syntax
Sequence ']]>' not allowed in content
The three characters ]]> are reserved as the CDATA terminator and cannot appear literally in element content, even outside a CDATA section.
Sequence ']]>' not allowed in content (line 2)What it means
XML forbids the literal sequence ]]> in character data anywhere, not only inside a CDATA section. The rule exists so a parser scanning for the end of a section can never be fooled by content that merely looks like one.
The usual real-world version is worse than a stray literal: a CDATA section whose own content contains ]]>, which terminates the section early and leaves the remainder to be parsed as markup.
What usually causes it
- Embedding a code sample, a regular expression or serialized XML that happens to contain ]]>.
- Nesting CDATA — wrapping content that already contains a CDATA section, which cannot be done directly.
- A generator that wraps arbitrary text in CDATA without scanning it for the terminator first.
- Concatenating two CDATA-wrapped fragments so that one's terminator lands inside the other.
How to fix it
- Escape the closing bracket: write ]]> instead of ]]>.
- Split the sequence across two CDATA sections, ending the first after ]] and starting the next with >.
- Do not wrap in CDATA at all — escape the content normally with < and &, which is always safe.
- If a generator writes CDATA, make it replace ]]> in the payload before wrapping rather than after.
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 character sequence "]]>" must not appear in content unless used to mark the end of a CDATA section.expat (Python)
not well-formed (invalid token): line 2, column 7.NET System.Xml
']]>' is not allowed in character data.fast-xml-parser and similar
(accepted — no error reported at all)
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>a]]>b</root><?xml version="1.0"?>
<root>a]]>b</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
- 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
- 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.