| Free tutorials for Java, Eclipse and Web programming |
Version 1.1
Copyright © 2008 - 2009 Lars Vogel
08.12.2009
| Revision History | ||
|---|---|---|
| Revision 0.6 | 26.02.2008 | Lars Vogel |
| Sax, Dom, Stax | ||
| Revision 0.7 | 21.10.2008 | Lars Vogel / Marcus Rieck |
| Added Jaxb | ||
| Revision 0.7.1 | 20.02.2009 | Lars Vogel |
| Corrected typo in intro XML example | ||
| Revision 0.7.2 | 20.04.2009 | Lars Vogel |
| Fixed incorrect package and setter in JAXB example | ||
| Revision 0.8 | 21.07.2009 | Lars Vogel |
| Valid XML | ||
| Revision 0.9 | 05.11.2009 | Lars Vogel |
| Improved Stax reader example with nestled XML elements | ||
| Revision 1.0 | 06.11.2009 | Lars Vogel |
| Added link to RSS article | ||
| Revision 1.1 | 08.12.2009 | Lars Vogel |
| fixed example XML (comment was not closed) | ||
Table of Contents
XML stands for Extensible Markup Language and was defined 1998 by the World Wide Web Consortium (W3C).
A XML document consists out of elements, each element has a start tag, content and an end tag. A XML document must have exactly one root element, e.g. one tag which encloses the remaining tags. XML makes a difference between capital and non-capital letters.
A XML file is required to be well-formated.
Well-formated XML must apply to the following conditions:
A XML document always starts with a prolog (see below for an explanation of what a prolog is)
Every tag has a closing tag.
All tags are completely nested.
A XML file is valid if it is well-formated and if it is contains a link to a XML schema and is valid according to the schema.
In general the following is considered as advantages in using XML for data processing / representation.
XML is Plain text
XML allows the data identification without any display information
Style can be defined via XSL
Easily processed due to it regular and consistent notation
XML files are hierarchical
The following is a valid, well-formated XML file.
<?xml version="1.0"?> <!-- This is a comment --> <address> <name>Lars </name> <street> Test </street> <telephon number= "0123"/> </address>
A XML document always starts with a prolog which describes XML file. This prolog can be minimal, e.g. <?xml version="1.0"?> or can contain other information, e.g. the encoding, e.g. <?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
A tag which doesn't enclose any content is know as an "empty tag". For example: <flag/>