&lt;     <     less than
&gt;     >     greater than
&amp;     &     ampersand
&apos;     '     apostrophe
&quot;     "     quotation mark

<!-- This is a comment -->

With XML, the white-space in a document is not truncated. HTML truncates multiple white-space characters to one single white-space:

<gangster name='George "Shotgun" Ziegler'>  OR  <gangster name="George &quot;Shotgun&quot; Ziegler">

Avoid XML Attributes?
Some of the problems with using attributes are:
    * attributes cannot contain multiple values (elements can)
    * attributes cannot contain tree structures (elements can)
    * attributes are not easily expandable (for future changes)

Sometimes ID references are assigned to elements.

  <note id="501">
    <body>Don't forget me this weekend!</body>
  <note id="502">
    <heading>Re: Reminder</heading>
    <body>I will not</body>

What I'm trying to say here is that metadata (data about data) should be stored as attributes, and that data itself should be stored as elements.

Well Formed XML Documents

  • XML documents must have a root element
  • XML elements must have a closing tag
  • XML tags are case sensitive
  • XML elements must be properly nested
  • XML attribute values must be quoted

Valid XML and DTD

<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE note SYSTEM "Note.dtd">
<body>Don't forget me this weekend!</body>

<!DOCTYPE note
<!ELEMENT note (to,from,heading,body)>
<!ELEMENT heading (#PCDATA)>

Subpages (4): JDOM JSON XPath XSLT