XML Elements Must Have a Closing

In HTML, you can get away with omitting the closing tag for many of its elements. For example, you can omit the closing tags </P> and </LI> for closing paragraphs and list elements, respectively.

<P>This is my paragraph. <LI>This is an item in my list.

In XML, all elements must have a closing tag. To distinguish a closing tag from an opening tag, you use a forward slash (/) inside the angle bracket of the second tag, as follows:

<p>This is my paragraph.</p> <li>This is an item in my list.</li> <name>Fred Flintstone</name>

In cases where tags do not have an ending tag (such as the <img> tag in HTML, used to define an image), you may use a single tag in XML, but you must also include a forward slash just before the closing angle bracket, as follows:

You may have noticed that the opening declaration in the XML test document does not have a closing tag. This is because the declaration is not an XML element, and is technically not even part of the XML document. The declaration begins with <? and ends with ?> to indicate that this is a special header line and not part of the document itself. There is, therefore, no violation of XML syntax.

Biorhythm Awareness

Biorhythm Awareness

Who else wants to take advantage of biorhythm awareness to avoid premature death, escape life threatening diseases, eliminate most of your life altering mistakes and banish catastrophic events from your life.

Get My Free Ebook

Post a comment