Skip to main content
IBM  
Shop Support Downloads
IBM Home Products Consulting Industries News About IBM
IBM developerWorks : XML : Education - Tutorials
Introduction to XML
ZIPPDF (letter)PDF (A4)e-mail
Main menuSection menuFeedbackPreviousNext
3. XML document rules
  


End tags are required page 5 of 10


You can't leave out any end tags. In the first example below, the markup is not legal because there are no end paragraph (</p>) tags. While this is acceptable in HTML (and, in some cases, SGML), an XML parser will reject it.


<!-- NOT legal XML markup -->
<p>Yada yada yada...
<p>Yada yada yada...
<p>...
          

If an element contains no markup at all it is called an empty element; the HTML break (<br>) and image (<img>) elements are two examples. In empty elements in XML documents, you can put the closing slash in the start tag. The two break elements and the two image elements below mean the same thing to an XML parser:


<!-- Two equivalent break elements -->
<br></br>
<br />

<!-- Two equivalent image elements -->
<img src="../img/c.gif"></img>
<img src="../img/c.gif" />
          

Main menuSection menuFeedbackPreviousNext
Privacy Legal Contact