In questo esempio viene descritto un DTD XML in un documento XML e il relativo formato di struttura ad albero:
<!DOCTYPE test PUBLIC "//this/is/a/URI/test" "test.dtd" [ <!NOTATION TeX PUBLIC "//this/is/a/URI/TexID" "//TexID"> <!ENTITY ent1 "this is an entity"> <!ENTITY % ent2 "#PCDATA | subel2"> <!ENTITY % extent1 PUBLIC "//this/is/a/URI/extent1" "more.txt"> <!ENTITY extent2 PUBLIC "//this/is/a/URI/extent2" "more.txt"> <!ENTITY unpsd PUBLIC "//this/is/a/URI/me.gif" "me.gif" NDATA TeX> <?test Do this?> <!--this is a comment--> <!ELEMENT subel2 (#PCDATA)> <!ELEMENT subel1 (subel2 | el4)+> <!ELEMENT el1 (#PCDATA)> <!ELEMENT el2 (#PCDATA | subel2)*> <!ELEMENT el3 (#PCDATA | subel2)*> <!ELEMENT el4 (#PCDATA)> <!ELEMENT el5 (#PCDATA | subel1)*> <!ELEMENT el6 (#PCDATA)> <!ATTLIST subel1 size (big | small) "big" shape (round | square) #REQUIRED> <!ATTLIST el5 el5satt CDATA #IMPLIED> ]>
Quando si analizza un messaggio con il programma di analisi XML generico, la parte rilevante dell'albero dei messaggi viene visualizzata come riportato di seguito (si presume che non siano presenti ritorni a capo o spazi vuoti tra i tag):
Nella struttura IntSubset sono contenute le seguenti strutture al livello successivo di nidificazione: la struttura ad albero di ciascuna di queste viene visualizzata nelle strutture ad albero riportate di seguito.