XML validation errors explained

Validators phrase the same rule differently: libxml2 (used by Python's lxml, PHP, xmllint and this site) says This element is not expected, Java's Xerces says cvc-complex-type.2.4.a: Invalid content was found. Each page below covers one rule with both wordings, typical causes, an example and the fix.

Error Xerces code
This element is not expected cvc-complex-type.2.4.a
Missing child element(s) cvc-complex-type.2.4.b
Not a valid value of the atomic type cvc-datatype-valid.1.2.1
The value is not accepted by the pattern cvc-pattern-valid
The value is not an element of the set cvc-enumeration-valid
Value too long or too short cvc-maxLength-valid
Value greater or less than allowed cvc-maxInclusive-valid
More digits than allowed cvc-totalDigits-valid
The attribute is required but missing cvc-complex-type.4
The attribute is not allowed cvc-complex-type.3.2.2
Character content is not allowed cvc-complex-type.2.3
No matching global declaration for the validation root cvc-elt.1.a
Duplicate key or missing key reference cvc-identity-constraint.4.2.2

Validate your XML file