Академический Документы
Профессиональный Документы
Культура Документы
Unit V
XML Introduction
XML is to represent structured data.
XML is the most widely used for transmitting
structured data over the Web.
Eg:
<text>
This is my first XML Document
</text>
XML Introduction
XML stands for eXtensible Markup Language.
XML is designed to transport and store data.
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
XML is a W3C Recommendation
XML Versions
XML 1.0 has been widely adopted without the
need for substantial modification.
W3C released an XML 1.1 recommendation in
2004
The W3C at the same time encouraged those
who do not need 1.1s (relatively few) new
features to continue to use XML 1.0.
XML Declaration
The XML recommendations suggest (but do not
require) that every XML document begin with a
special tag known as an XML declaration.
<?xml version="1.0"?>
This is used to specify the version of XML used
to write the document and optionally some
additional meta-information about the
document, such as the character set/encoding
used.
XML Declaration
An encoding other than one of default
encodings may be specified by including an
encoding declaration within the XML
declaration.
<?xml version="1.0" encoding="ISO-8859-1"?
>
the version and encoding declarations must appear
in the order shown.
XML Documents
XML is a software- and hardwareindependent tool for carrying information.
XML Separates Data from HTML
With a few lines of JavaScript code, you can
read an external XML file and update the data
content of your web page.
XML Documents
- basic XML syntax rules
1. An XML document consists of markup and
character data.
2. There are two types of markup: tags and references.
3. Tags begin with a less-than (<) character and end
with a greater-than (>) character.
4. References in an XML document begin with an
ampersand (&) and are of two types: character
references (such as  ) and entity references
(such as <).
XML Documents
- basic XML syntax rules
5. All XML documents may make references to
the entities lt(<), gt(>), amp(&), apos('), and
quot("), Other entities may also be defined,
depending on the XML DTD used and/or
application processing the document.
6. If not used to begin markup, the characters <
and & must be escaped (an exception is that
escaping is not necessary within comments
and CDATA sections).
XML Documents
- basic XML syntax rules
7. Element tags are of three types: start tags, end
tags (which begin with </), and empty element
tags (which end with />).
8. Character data may only appear within a
nonempty element.
9. Start and end tags must be paired and must be
properly nested with other pairs of start and
end tags.
XML Documents
- basic XML syntax rules
10. Attribute specifications may appear within
start tags or empty-element tags. Every
attribute specification consists of an attribute
name followed by an equals sign (=) followed
by a quoted attribute value. Attribute
specifications are white-space-separated from
one another.
11. Element and attribute names are case
sensitive.
XML Documents
- basic XML syntax rules
12. The XML white space characters are the
same as in XHTML: space, carriage return,
line feed, and tab.
13. XML comments begin with <!--, end with
-->, and may not contain the string -elsewhere within the content of the comment.
</message>
The CDATA section could be replaced with the
equivalent markup
<message>This & that</message>
XML Advantages
Different applications can access your data,
not only in HTML pages, but also from XML
data sources.
With XML, your data can be available to all
kinds of "reading machines" (Handheld
computers, voice machines, news feeds, etc.),
and make it more available for blind people, or
people with other disabilities.
XML Tree
<?xml version="1.0" encoding="UTF-8"?>
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!
</body>
</note>
XML Tree
Example:
<bookstore>
<book category="COOKING">
<title lang="en">Everyday
Italian</title>
<author>Giada De Laurentiis</author>
<year>2005</year>
<price>30.00</price>
</book>
<book category="CHILDREN">
<title lang="en">Harry Potter</title>
<author>J K. Rowling</author>
<year>2005</year>
<price>29.99</price>
</book>
<book category="WEB">
<title lang="en">Learning XML</title>
<author>Erik T. Ray</author>
<year>2003</year>
<price>39.95</price>
</book>
</bookstore>