While not required, creating a DTD for your document forces all documents referencing this DTD to comply completely with the definition. An XML parser acts similar to a compiler in that it validates each document against its DTD before opening and parsing the document. Any noncompliance with the DTD will result in errors being generated. The two most common ways to store data within an XML document are elements and attributes. Elements are structured items within the document that are denoted by opening and closing element tags.
Elements can also contain sub-elements as well.
Attributes, meanwhile, are generally used to describe an element. In the code above, the City element contains the name and state attributes. Additional elements contained within the City element give information on that city's professional sports teams. An entire data set could be contained within an XML document to describe all of the North American cities who host professional sports teams. At the time of this writing, only Microsoft Internet Explorer 5.0 supported this although Netscape has announced support in their upcoming Navigator 5.0 release.