11. DTD for Elements with Children

Elements having one or more children are defined with the name of the children elements inside parentheses. The children must also be declared and they can also have children.

Example 11.1 An Element with One Child Element
<?xml version="1.0" standalone="yes"?>
<!DOCTYPE rootelement [
<!ELEMENT rootelement (childelement)>
<!ELEMENT childelement (#PCDATA)>
]>
<rootelement>
	<childelement>Child element.</childelement>
</rootelement>	
	

Children can be declared in a sequence using the comma separator. However, the children must appear in the same sequence in the document.

Example 11.2 Children Declared as a Sequence
<?xml version="1.0" standalone="yes"?>
<!DOCTYPE rootelement [
<!ELEMENT rootelement (childelement1, childelement2)>
<!ELEMENT childelement1 (#PCDATA)>
<!ELEMENT childelement2 (#PCDATA)>
]>
<rootelement>
	<childelement1>Child element 1.</childelement1>
	<childelement2>Child element 2.</childelement2>
</rootelement>