XML simpletype, simplecontent, complextype, complexcontent
What is a Complex Element?
A complex element is an XML element that contains other elements and/or attributes. There are four kinds of complex elements:
- empty elements
- elements that contain only other elements
- elements that contain only text
- elements that contain both other elements and text
Note: Each of these elements may contain attributes as well!
Examples of Complex Elements
- A complex XML element, "product", which is empty:
<product pid="1345"/>
- A complex XML element, "employee", which contains only other elements:
<employee>
<firstname>Deepam</firstname>
<lastname>Gupta</lastname>
</employee>
- A complex XML element, "food", which contains only text:
<food type="dessert">Chapati</food>
- A complex XML element, "description", which contains both elements and text:
<description>
It happened on <date lang="hindi">18.03.99</date> ....
</description>
I know it's a bit late but I hope this article helps someone.
In short:
<complexType>
and <simpleType>
both define types. Complex types can have element descendants and attributes while simple types can't.
Complex types can have simple or complex content. Types with <complexContent>
can contain child elements while those with <simpleContent>
can only contain characters.