and
XML
Beginner
1 min read
Element Content Models
and
Example
<?xml version="1.0" encoding="UTF-8"?>
<!--
Demonstrating the four XML content models
-->
<examples>
<!-- 1. ELEMENT CONTENT: only child elements, no direct text -->
<person>
<firstName>Jane</firstName>
<lastName>Doe</lastName>
<age>28</age>
</person>
<!-- 2. MIXED CONTENT: text and child elements interleaved -->
<paragraph>
This is <emphasis>very</emphasis> important and
<link href="http://example.com">click here</link> for details.
</paragraph>
<!-- 3. EMPTY ELEMENT: no content whatsoever -->
<pageBreak/>
<image src="photo.jpg" width="800" height="600"/>
<!-- 4. ANY CONTENT: unconstrained (avoid in strict schemas) -->
<freeform>
Text, <child>elements</child>, and <b>anything</b> goes.
42 <nested><deep>value</deep></nested>
</freeform>
</examples>