More XML
Under construction
Elements
XML has elements defined by tags, just like HTML. XML elements, however, must always be closed. This is sometimes done by a closing tag which matches the opening tag (including the case of its first letter which may be upper or lower), but with a forward slash, such as:
<body>
This element is closed by a tag which is matches the opening tag
</body>
or, in the case of an empty element, which XML supports, by the forward slash being merged in with the opening tag as follows:
<img src="MyImg.gif"/>
which is equivalent to:
<img src="MyImg.gif">
</img>
In XML you cannot have unclosed tags like HTML's <paragraph> and <br> (and HTML does not allow <br/>).
Attributes
XML allows you to specify attribute values, just like HTML...
<img src="MyImg.gif">
</img>
... but ALL attribute values must be enclosed in quotes (single or double).
Nested tags
In XML, all tags MUST be nested correctly, e.g. <i><b>text to be italicised and emboldened</b></i> rather than <i><b>text to be italicised and emboldened</i></b>.
XML documents
It generally takes three files for an XML-compliant application to display XML content: the XML document which contains the tagged data, a stylesheet (or more than one different stylesheet) which specifies how the document elements should be displayed, and a DTD (Document Type Definition) containing the definitions of the elements, attributes and data and their logical relationships.
A simple XML document looks like this (left hand column):
<?xml version="1.0" standalone="no"?> |
' | The XML Declaration comes within the <?xml and the ?>. |
|
' | It specifies that this is an xml document conforming to version 1.0 of XML. |
|
' | standalone="no" means that an external DDT is required. |
<!DOCTYPE Sue:Pages SYSTEM "sue.dtd"> |
' | This specifies that the root element is Sue:Pages, |
|
' | that the DTD to be used is "sue.dtd", a local file. |
|
' | The Sue: denotes the (optional) namespace. |
<!-- Start of XML data --> |
' | This is a comment. It must not come inside a tag or before the XML declaration. |
<Sue:Pages xmlns:Sue='myURL'> |
' | This is an XML element that I made up. |
|
' | xmlns:Sue='myURL' declares the namespace Sue. |
<Sue:Topic>XML</Sue:Topic> |
' | This is an XML elenment that I made up. |
<Sue:Link>DTD</Sue:Link > |
' | This is an XML elenment that I made up. |
</Sue:Pages> | ' |
XML Declaration
This provides information for the application processing the XML document, such as XML standard version and whether or not a DTD is required.
Root Element
This is the outermost element in an XML document.
Namespace
The namespace is the portion before the colon in a statement such as the Sue in <Sue:Topic>XML</Sue:Topic>.
