Empty Elements : Well Formed « Introduction « XML Tutorial






Sometimes an element has no PCDATA. 


<name nickname='007'> 
    <first>James</first> 
    <middle></middle <!--James does not have middle name -->  > 
    <last>Bond</last> 
</name> 

You can write this element using a self-closing tag: 

<middle/> 

The / and > always have to be together

<middle /> or this  <middle/> 

but not like this <middle/ > or this <middle / > 

Empty elements are used for elements with no PCDATA but attributes. 

<name first="Bond" 
      middle="James" 
      last="Last"/>








1.3.Well Formed
1.3.1.XML documents must adhere to certain rules to be well formed.
1.3.2.XML Naming Conventions
1.3.3.Case Sensitivity
1.3.4.Writing Non-Empty Elements
1.3.5.Nesting Elements
1.3.6.Empty Elements