Naming conventions

Element names must conform to the following rules:

  • Names consist of one or more nonspace characters. If a name has only one character, that character must be a letter, either uppercase (A-Z) or lowercase (a-z).

  • A name can only begin with a letter or an underscore.

  • Beyond the first character, any character can be used, including those defined in the Unicode standard (http://www.unicode.org/).

  • Element names are case sensitive; thus, PatientName, PATIENTNAME, and patientname are considered different elements.

For example, the following element names are well formed:


These element names would not be considered well formed:

  Fred 123

Here the first element name contains a space, the second begins with a dash, and the third begins with a numeral instead of a letter or an underscore.


An attribute is a mechanism for adding descriptive information to an element. For example, in our patient record XML document, we have no idea whether the patient's weight is measured in pounds or kilograms. To indicate that PatientWeight is given in pounds, we would add a unit attribute and specify its value as LB:

  <PatientWeight unit="LB">155</PatientWeight>

Attributes can be included only in the begin tag, and like elements they are case-sensitive. Attribute values must be enclosed in double quotation marks (").

Attributes can be used with empty elements, as in the following well-formed example:

  <PatientWeight unit="LB"/>

In this case, this might mean that the patient weight is unknown or it has not yet been entered into the system.

An attribute can be declared only once in an element. Thus, the following element would not be well formed:

  <PatientWeight unit="LB" unit="KG">155</PatientWeight>

This makes sense because the weight cannot be both kilograms and pounds.


Comments are descriptions embedded in an XML document to provide additional information about the document. Comments in XML use the same syntax as HTML comments and are formatted so that they are ignored by the application processing the document, as shown here:

  <!-- Comment text -->
by BrainBellupdated