XML is a markup language that is used to store data in a self-explanatory manner.
Making the data "self-explanatory" comes about by containing information in
elements. If a piece of text is a title then it will be contained
within a "title" element.
A tag is just a generic name for a <element>.
An opening tag looks like <element>, while a closing tag has a slash
that is placed before the element's name: </element>. From now on we will
refer to the opening or closing of an element as open or close tags. All information
that belongs to an element must be contained between the opening and closing tags
of an element.
Attributes are used to specify additional information about the element. It
may help to think of attributes as a means of specializing generic elements to fit
your needs. An attribute for an element appears within the opening tag.
If there are multiple values an attribute may have, then the value of the
attribute must be specified. For example, if a
tag had a color attribute then the value would be: red, blue, green, etc. The syntax
for including an attribute in an element is:
- <element attributeName="value">
In this example we will be using a madeup XML element named "friend" that has an optional
- Elements are used to classify data in an XML document so that the data
- Opening and closing tags represent the start and end of an element.
- Attributes are used to include additional information on top of the
data that falls between the opening and closing tag.
Download Tizag.com's XML Book
If you would rather download the PDF of this tutorial, check out our
XML eBook from the Tizag.com store.
Found Something Wrong in this Lesson?
Report a Bug or Comment on This Lesson - Your input is what keeps Tizag improving with time!