XML documents (and HTML documents) are made up by following building blocks:
· Elements · Tags · Attributes · Entities · PCDATA · CDATA
This is a brief explanation of each of building blocks:
Elements are main building blocks of both XML and HTML documents.
Examples of HTML elements are "body" and "table". Examples of XML elements could be "my-schedule" and "date". Elements can contain text, other elements, or be empty. Examples of empty HTML elements are "hr", "br" and "img".
Tags are used to markup elements.
A starting tag like mark up beginning of an element, and an ending tag like mark up end of an element.
A body element: body text in between. A message element: some message in between
Attributes provide extra information about elements.
Attributes are placed inside start tag of an element. Attributes come in name/value pairs. The following "img" element has an additional information about a source file:
The name of element is "img". The name of attribute is "src". The value of attribute is "computer.gif". Since element itself is empty it is closed by a " /".
PCDATA means parsed character data.
Think of character data as text found between start tag and end tag of an XML element.
PCDATA is text that will be parsed by a parser. Tags inside text will be treated as markup and entities will be expanded.
CDATA also means character data.
CDATA is text that will NOT be parsed by a parser. Tags inside text will NOT be treated as markup and entities will not be expanded.
Entities as variables used to define common text. Entity references are references to entities.
Most of you will known HTML entity reference: " " that is used to insert an extra space in an HTML document. Entities are expanded when a document is parsed by an XML parser.