eWebProgrammer eweb  

XML Programming  «Prev 

Importance of starting and ending Tags in XML

In HTML, you became familiar with the fact that you could use the following syntax to create a bulleted list:
<LI>Bullet list item one
<LI>Bullet list item two
<LI>Bullet list item three
Note that the <UL> and </UL> tags denote the beginning and ending of an unordered list. <LI> denotes the beginning of the current list item, but also can be inferred to denote the end of the previous list item in its second and third appearance. In other words, the end of the element has been inferred. If you were to code like this in an XML document, however, the browser would be instructed not to render this page because it is not well-formed.

In XML, tags will never be inferred and must always be made explicit. In other words, if the above example were to be included in an XML document, it would have to be written like this:
<LI>Bullet list item one</LI>
<LI>Bullet list item two</LI>
<LI>Bullet list item three</LI>
In the second instance of this list, you see that each list item is enclosed between beginning and ending tags, meeting one criterion for a well-formed XML document.