The Empty element

Elements that do not have text nodes, nor other elements as children, can be expressed as empty elements.

The syntax for empty elements is slightly different:


  <elementName />

Note that this element does not have an opening and a closing tag! They are merged into one.

Empty elements often have attributes that contain additional information. Example:


  <image file="/myImages/image.png" />

In this example, the attribute "file" contains a pointer to an image.

practice

Add the empty element added as the first child of the root. Add to this element the attribute date with todays date as the value.

Does the date attribute value follow the international standard for dates?

The international standard for dates (ISO 8601) uses the date format yyyy-mm-dd. Make sure the date value you added complies with this standard.

Add a scheme attribute to the added element that makes it explicitly clear that the date format used ISO 8601.