activity 14.1 XML


Question: What are the key rules that you need to follow when creating any XML document (such as the XHTML we've been creating since day one!):

  1. Every element must have an opening and closing tag
  2. Each document must have one and only one root element
  3. Attributes must have either single or double quotes around the text
  4. Special characters must be escaped (<, >, &, " and ')

These requirements actually ensure that the XML document is well-formed. If you didn't manage to identify five or six requirements (or even if you did), do a bit of research to find out what the requirements for a well-formed xml (or xhtml) document are. Hopefully you'll find that you've been doing these since you started to learn XHTML!

But does it mean that your document is valid? Here's an example snippet of some XHTML that uses mixed content:

<p>A paragraph of text that is <strong>really important</p></strong>

Now here's a snippet of XHTML that is well-formed and uses mixed content.

<p>A paragraph of text that is <bananas>really important</bananas></p>

OK, so that example might be very obvious, here's another snippet of XHTML that is well-formed but also uses mixed content.

<p>A paragraph of text with a list: <ul><li>Point 1</li><li>Point 2</li></ul></p>

A file is valid if it passes validation with an XML Schema.