- Markup Languages
- What Does XML Look Like?
- What Does XML Look Like in a Browser?
- What's So Great About XML?
- Well-Formed XML Documents
- Valid XML Documents
- Parsing XML Yourself
- XML Resources
- XML Editors
- XML Browsers
- XML Parsers
- XML Validators
- CSS and XSL
- XLinks and XPointers
- URLs Versus URIs
- ASCII, Unicode, and the Universal Character System
- XML Applications
Well-Formed XML Documents
What does it mean for an XML document to be well formed? To be well formed, an XML document must follow the syntax rules set up for XML by the World Wide Web Consortium in the XML 1.0 specification (which you can find at http://www.w3.org/TR/REC-xml, and which we'll discuss in more detail in the next chapter). Informally, well-formedness often means that the document must contain one or more elements, and one element, the root element, must contain all the other elements. Also, each element must nest inside any enclosing elements properly. For example, this document is not well formed because the </GREETING> closing tag comes after the opening <MESSAGE> tag for the next element:
<?xml version="1.0" encoding="UTF-8"?> <DOCUMENT> <GREETING> Hello From XML <MESSAGE> </GREETING> Welcome to the wild and woolly world of XML. </MESSAGE> </DOCUMENT>