Missing child element(s) (cvc-complex-type.2.4.b)

The message

libxml2 (Python lxml, PHP, xmllint, this site):

Element 'R': Missing child element(s). Expected is ( B ).

Java / Xerces:

cvc-complex-type.2.4.b: The content of element 'R' is not complete. One of '{B}' is expected.

What it means

An element ended before all its required children appeared. Every child with minOccurs greater than zero (the default is 1) must be present.

Typical causes

Example

Schema:

<xs:sequence>
  <xs:element name="Id"/>
  <xs:element name="Currency"/>  <!-- minOccurs defaults to 1 -->
</xs:sequence>

Document:

<Amount>
  <Id>1</Id>
</Amount>   <!-- Currency is missing -->

How to fix it

Add the elements listed after Expected is. If the data really is unknown, check whether the schema offers an alternative (xs:choice) or whether the element should be optional in your version of the schema.

Find every occurrence at once

Load your XML file and its schema in the XML Online Viewer: it lists all validation errors with line, path and the surrounding lines, jumps to each one in the tree, and exports the list to Excel to hand to whoever produces the file. The schema is detected from xsi:schemaLocation when the document names it.

Other errors: all XML validation errors explained.

Validate your XML file