XML naturally represents hierarchical data structures by nesting elements inside one another. Parent elements contain child elements, forming a tree-like structure that is easy for both humans and machines to understand.

Example: Nested elements

<library>
    <book>
        <title>XML Basics</title>
        <author>Jane Doe</author>
    </book>
</library>

The <library> element contains a <book>, which itself contains more detailed elements.