O'Reilly logo

XML and Perl by Ilya Sterin, Mark Riehl

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Defining the Structure and Content of an XML Document

Two main approaches to defining the format and contents of XML documents are Document Type Definitions (DTDs) and XML schemas. However, before discussing DTDs and XML schemas, let’s discuss the format of an XML document.

Well-Formed and Valid XML Documents

XML documents are considered well-formed if they follow the rules in the XML specification regarding document structure. Let’s take a look at some of the more important points related to well-formed documents.

An XML document can only have one root element, that is, the top level of the document tree. For example, in the following XML document, the root element is named <employees>:

 <?xml version="1.0" encoding="UTF-8"?> <employees> ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required