8. XML Document Structure

Example 8.1 An XML document
<?xml version="1.0" encoding="ISO-8859-1"?>
<rootelement>
	<childelement1 attribute1="An attribute value.">An element value.</childelement1>
	<childelement2>An element value.</childelement2>
	<childelement3/>
	<childelement4>
		An element value.
		<childelement4childchildelement1>
			An element value.
		</childelement4childchildelement1>
		<childelement4childchildelement2>
			An element value.
		</childelement4childchildelement2>
	</childelement4>
</rootelement>
	

The first line in an XML document defines the version and character encoding used.

Example 8.2 XML Declaration
<?xml version="1.0" encoding="ISO-8859-1"?>
	
Example 8.3 XML Root Begin
<rootelement>
	
Example 8.4 XML Child Elements
<childelement1 attribute1="An attribute value.">An element value.</childelement1>
<childelement2>An element value.</childelement2>
<childelement3/>
<childelement4>
	An element value.
	<childelement4childchildelement1>
		An element value.
	</childelement4childchildelement1>
	<childelement4childchildelement2>
		An element value.
	</childelement4childchildelement2>
</childelement4>
	
Example 8.5 XML Root Element End
</rootelement>