XML Examples

XML Overview
<?xml version="1.0" standalone="no"?>
<omf>
 <resource>
  <person>
   <creator>
    <firstName>Gwendolyn</firstName>
    <surname>Midlo</surname>
    <organization>Rutgers University</organization>
<email>ghall1929@aol.com</email> </creator> <maintainer> <firstName>Andre</firstName> <surname>Burton</surname> <organization>ibiblio.org</organization> <email>burta@unc.edu</email> </maintainer> </person> <title>Louisiana Slave Database</title> <date>2000-03-05</date> <description> Poring through documents from all over Louisiana, as well as archives in France, Spain and Texas, Dr. Hall designed and created a database into which she recorded and calculated the information she obtained from these documents about African slave names, genders, ages, occupations, illnesses, family relationships, ethnicity, places of origin, prices paid by slave owners, and slaves' testimony and emancipations. </description> <identifier url="http://ibiblio.org/laslave" /> <keyword>slavery</keyword> <keyword>genealogy</keyword> <language name="English" code="EN" /> <format>text</format> <format>dBase</format> <relation>http://www.rootsweb.com/~ilissdsa/ </relation> </resource> </omf>

 

HTML
<head>
 <title>Movie Starz Movies</title>
</head>
<body>
 <dt>Electric Ladyland
 <dd>by Jimi Hendrix
 <ul>
  <li>1968
  <li>MCA
  <li>$13.88
  <li>CD
  <li>Cassette
 </ul>
</body>
vs XML
<album>
 <title>Electric Ladyland</title>
 <composer>Jimi Hendrix</composer>
 <producer>Jimi Hendrix</producer>
 <label>MCA</label>
 <year>1968</year>
 <price>13.88</price>
 <format>CD</format>
 <format>Cassette</format>
</album>

 

Hello World!
<?xml version="1.0" standalone="yes"?>
<greeting> <message>Hello World</message> </greeting>

 

Well-formedness
Well-formed
<Album></Album>
<album></album>
<payRate></payRate>
<PRICE></PRICE>
<employee.number></employee.number>
<_copyright></_copyright>
<dc:format></dc:format> (colon reserved for namespaces)
Non-matching tags
<Album></album>
<price></PRICE>

Empty tags
<hr />
<img src="blank.gif" />
<language name="english" />

Proper nesting
<person><surname>Burton</surname></person>
Improper nesting
<person><surname>Burton</person></surname>
Use entity references
&amp; for &
&lt; for <
&gt; for >
&quot; for "
&apos for '
Document Type Declaration
<?xml version="1.0" standalone="no"?>
One root element
<album>
<title>Electric Ladyland</title>
</album>