What
is XML?
XML
stands for Extensible Markup Language which is much like HTML. XML was designed
to carry data, not to display data.
XML
tags are not predefined. You must define your own tags. XML is designed to be
self-descriptive.
Features of XML:
1.
With XML You Invent Your Own Tags
2.
XML Separates Data from HTML
3.
XML Simplifies Data Sharing
4.
XML Simplifies Data Transport
XML Syntax Rules:
All XML Elements Must
Have a Closing Tag.
XML Tags are Case
Sensitive.
XML Elements Must be
Properly Nested.
XML Documents Must
Have a Root Element.
XML Attribute Values
Must be quoted.
Comments
in XML:
The syntax for writing comments in XML is
similar to that of HTML.
<! -- This is a
comment -->
What
is an XML Element?
An
XML element is everything from (including) the element's start tag to
(including) the element's end tag. An element can contain other elements,
simple text or a mixture of both. Elements can also have attributes.
E.g. XML Example
<?xml version="1.0" encoding="UTF-8"?>
<weather>
<day1>
<location>Sanfransico</location>
<date>20/04/2013</date>
<temp>20'c</temp>
</day1>
</weather>
In the example above, <weather>
and <day1> have element
contents, because they contain other elements. <location> has text content because it contains
text.
XML
Naming Rules
XML elements must follow
these naming rules:
Names can contain letters,
numbers, and other characters
Names cannot start with a
number or punctuation character
Names cannot start with the
letters xml (or XML, or Xml, etc)
Names cannot contain spaces
Any name can be used, no words are reserved.
Well
Formed XML Documents:
A "Well Formed"
XML document has a correct XML syntax.
XML Namespaces
XML Namespaces provide a method to
avoid element name conflicts
Name Conflicts
In XML, element names are defined by the developer.
This often results in a conflict when trying to mix XML documents from
different XML applications.
XML
Namespaces - The xmlns Attribute
When using prefixes in XML, a so-called namespace
for the prefix must be defined. The namespace is defined by the xmlns attribute
in the start tag of an element. The namespace declaration has the following
syntax. xmlns: prefix="URI".
Uniform Resource Identifier (URI)
A Uniform Resource Identifier (URI) is a string of
characters which identifies an Internet Resource. The most common URI is the
Uniform Resource Locator (URL) which identifies an Internet domain address.
Another, not so common type of URI is the Universal Resource Name (URN).