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:

  1. empty elements
  2. elements that contain only other elements
  3. elements that contain only text
  4. elements that contain both other elements and text

Note: Each of these elements may contain attributes as well!

Examples of Complex Elements

  1. A complex XML element, "product", which is empty:
<product pid="1345"/>
  1. A complex XML element, "employee", which contains only other elements:
<employee>
    <firstname>Deepam</firstname>
    <lastname>Gupta</lastname>
</employee>
  1. A complex XML element, "food", which contains only text:
<food type="dessert">Chapati</food>
  1. 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.

Tags:

Xml

Xsd