# This element is not expected

Source: https://xmlvalid.com/errors/this-element-is-not-expected

> An element is in the wrong place: out of order, misspelt, or not allowed there.

Example message: `Element 'qty': This element is not expected. Expected is ( id ).`

## Why it happens

- Elements in a different order than the schema's `xs:sequence` requires: the order matters.
- A misspelt name or a different letter case.
- The element in the wrong namespace: the schema expects `{urn:…}qty`, the document has `qty` without a namespace, or the other way round.
- An element the schema doesn't allow at all there, or one too many of it (`maxOccurs`).

## How to fix it

- The message lists what the schema expected at that point. If the expected element is there but later, reorder; if it is missing, add it before; if the names look the same, compare their namespaces.

## Example that fails

```xml
<order currency="EUR">
  <qty>1</qty>
  <id>A-1</id>
</order>
```

## Fixed

```xml
<order currency="EUR">
  <id>A-1</id>
  <qty>1</qty>
</order>
```
