XML documents can be validated against a schema or definition that specifies the allowed structure and data types. This ensures that the document follows a predefined format and contains the expected elements and values.

Example: XML with schema reference

<book xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:noNamespaceSchemaLocation="book.xsd">
    <title>XML Guide</title>
    <author>Jane Doe</author>
</book>

The document references a schema file that defines the expected structure.