When is XML document well-formed?

The most current version as of .

Example of a well-formed XML document
<?xml version="1.0"?>
<solar-system>
    <stars>
        <star>Sun</star>
    </stars>
    <planets>
        <planet>Earth</planet>
        <planet>Mars</planet>
    </planets>
</solar-system>

XML is well-formed when it meets the following conditions:

The XML document has …

  1. … a XML declaration (<?xml version="1.0"?>)

  2. … at least one data element (<star>…</star>, <planet>…</planet>, …)

  3. … a only one root element (<solar-system>…</solar-system>)

Note
A well formed XML document is not necessarily valid.
— David Wolf