If all elements in the document that are opened (<elementName>)
are also closed (</elementName>) at their respective nesting level, this means that the document is wellformed. Wellformedness is a fundamental requirement.
Else, it is malformed. Malformedness is a fundamental error.
Example of malformedness:
<name>
<first-name>Miki
<last-name>Azuma</last-name>
</name>
The example above is malformed XML because the first-name element was not closed.
Another example of malformedness:
<name>
<first-name>This is the text</last-name>
</name>
The example above is malformed XML because the first-name element was not closed, and because there was a closing tag for an element last-name which was not open.
Another example of malformedness:
<document>
<paragraph>
<sentence>
This is a sentence inside a paragraph.
</paragraph>
</sentence>
</document>
The example above is malformed XML because the paragraph element was closed before the sentence element was closed. Elements must be closed at the same nesting level as they were opened.