An Introduction to XML
This section covers:
What is XML?
- XML stands for eXtensible Markup Language
- XML is a markup language much like HTML
- XML was designed to carry data, not to display data
- XML is designed to be very descriptive
- XML is a W3C Recommendation
Snippet of XML:
1 2 3 4
This example contains one parent element, a
This element is started with the opening
It has meta information that is described through the use of attributes.
note element has two attributes:
note element has two child elements:
These elements don't have any attributes but do have some text content.
Like HTML, XML uses tags to open and close elements. Unlike HTML, all tags in XML MUST be closed with either a closing tag:
Or self closing:
An XML element is everything from (and including) the element's start tag to (and including) the elements end tag. An element can contain:
- Other elements (children)
- Or a mix of all of the above...
Attributes provide additional pieces of information about the information being stored in the XML.
The attributes in the note example above show the
from recipients of the note, whereas the actual text of the subject and the body are child elements.
XML has a couple of character limitations.
If you need to use any of the following characters within an element you must use the
entity reference alternative:
For example if Alice's message to Bob was to 'get milk & bread', then it would be need to written as:
Comments can be added into XML using the following syntax:
Comments cannot include other comments (nested comments) nor can comments contain double dashes '--'.
For more info on XML visit: W3Schools