Xerces has reached a child whose expanded name cannot occupy the current position in its parent. The document may be perfectly well-formed XML. Validation fails because the parent’s content model expects something else at this point.
What the message literally means
The phrase “starting with element” identifies the first child that cannot be consumed. The expected set describes the next legal transition, rather than every element that appears anywhere in the schema. In this order, quantity must precede price; moving price after quantity repairs the sequence without changing either value.
Three common causes to check first
Children appear in a different order from xs:sequence. A serializer that sorts properties alphabetically can produce valid tags in an invalid sequence.
A required predecessor is missing. Adding the child named in the message at the end may still fail, because it belongs before the reported element.
The child has the wrong namespace, spelling or parent. A declaration elsewhere in the XSD does not make that element legal in every container.
Repair and retest
Locate the declaration of the reported parent, then walk its sequence or choice from the first child. Stop at the earliest mismatch and compare that child with the expected set. Fix the ordering in the producer rather than repeatedly moving whichever element the latest message names. Retest the full document because an early mismatch can hide later failures.
When this is a namespace problem
Suspect namespaces when the expected local name already matches the visible tag. Compare the namespace URI and local name together, including inherited xmlns declarations. A prefix change alone does not change identity when it remains bound to the same URI; removing a prefix can change identity when no matching default namespace exists.
Reading equivalent reports
In System.Xml.Schema this example says “has invalid child element”; libxml2 says “This element is not expected”. These phrases describe the same tested sequence failure. Do not replace xs:sequence with xs:any merely to silence it: the receiving application may still require the original field order.
Complete tested XML and XSD pairs
Open either variant in the workbench, then choose Validate XML. Loading an example does not run validation or send documents; server checks require the existing permission checkbox.
cvc-complex-type.2.4.a: Invalid content was found starting with element 'price'. One of '{quantity}' is expected.
PASS
.NET 8.0.33 · System.Xml.Schema Validation
The element 'order' has invalid child element 'price'. List of possible elements expected: 'quantity'.
PASS (no warnings)
XSDHub libxml2/WASM 0.7.2 Validation
Element 'price': This element is not expected. Expected is ( quantity ).
PASS
XSDHub xmlschema 4.3.1 · XSD 1.0 Validation
Unexpected child with tag 'price' at position 1. Tag 'quantity' expected.
PASS
Saxon
EE comparison: cvc-complex-type.2.4.a describes the corresponding XSD constraint. No Saxon-EE run or wording is claimed; an EE licence is unavailable in this test environment. Saxon-HE does not provide XSD validation.
The corrected results apply to these self-contained XSD 1.0 specimens. They do not establish business-rule acceptance for a different document or schema version.