XML
eXtensible Markup Language
- About
Differences from HTML
- XML elements must have a closing tag
- XML tags are case sensitive
- All XML elements must be properly nested
- All XML documents must have a root tag. The first tag in
an XML document is the root tag.
- Attribute values must always be quoted With XML, it is illegal
to omit quotation marks around attribute values
|
Rules in creating XML tags
Naming elements
- can contain letters, numbers, and other characters
- Names must not start with a number or punctuation character
- Names must not start with the letters xml (or XML or Xml
..)
- Names cannot contain spaces
- The ":" should not be used in element names because it is
reserved to be used for something called namespaces
|
Attributes
|
Example
<?xml version="1.0" encoding="ISO-8859-1">
<note>
<to>Butch</to>
<from>Allen</from>
<heading>Play time</heading>
<body>I will be returning from campus and hope to find
you well. </body>
</note>
|
viewing code
The first line in the document - the XML declaration - defines the XML
version and the character encoding used in the document. In this case
the document conforms to the 1.0 specification of XML and uses the ISO-8859-1
(Latin-1/West European) character set.
The next line describes the root element of the document (like it was
saying: "this document is a note"):
The next 4 lines describe 4 child elements of the root (to, from, heading,
and body)
Whats going on???
Since XML tags are "made up" or "invented" by the author of the XML document,
we cannot know if a tag like <table> describes a HTML type of table,
or if it describes a wooden kitchen table. Without
any information about how to display the data, most browsers will just
display the XML document as it is.
To specify display properties:
To Specify the XML tags:
- You need a DTD or an XML
schema|
There are other possibilities being explored:
- RELAX Regular Language description for XML
- SOX Schema for Object-oriented XML
- Schematron Schema for Object-oriented XML
Data Binding???
Data Islands can be bound to HTML elements (like HTML tables). In the
example below, an XML Data Island with an ID "cdcat" is loaded from an
external XML file. An HTML table is bound to the Data Island with a data
source attribute, and finally the tabledata elements are bound to the
XML data with a data field attribute inside a span.
(works on only some browsers)
<html>
<body>
<xml id="cdcat" src="cd_catalog.xml"> </xml>
<table border="1" datasrc="#cdcat">
<tr>
<td><span datafld="ARTIST"></span></td>
<td><span datafld="TITLE"></span></td>
</tr>
</table>
</body>
</html>
|
see it working |
cd_catalog.xml file |
Applications
VoiceXML, More
VoiceXML
XMLSoap
|