XML
XML
XML
m (XML)
By:
Anupam Kumar
Outline of Presentation
6ntroduction
Comparison between XML and HTML
Building Blocks of XML.
XML Elements
XML Tree
XML Data 6sland
DTD
Summary.
at is 6
6 stands for m6 mm
m
Markup language for documents containing
structured information
XML is a markup language 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.
6
Based on Standard Generalized Markup
Language (SGML)
Version 1.0 introduced by World Wide Web
Consortium (W3C) in 1998
Bridge for data exchange on
the Web
{omparisons
6
Extensible set of tags Fixed set of tags
XML was designed to HTML was designed
transport and store
data, with focus on to display data, with
what data is. focus on how data
Standard Data looks
infrastructure No data validation
Allows multiple output capabilities
forms
Single presentation
White-space is
Preserved in XML. Not in HTML.
9uilding blocks for 6
lements : are the main building blocks of
both XML and HTML documents .
~ttributes : provide extra information
about elements .
P{ ~~ : Parsed character data, will be
examined by parser for entities & markup.
{ ~~ : Character data is used about
text data that should not be parsed by the
6 parser.
6 lements
XML document must contain a root element. This
element is parent of all other elements.
An XML element is made up of a start tag, an end tag,
and data in between.
Example:
<director> Matthew Dunn </director>
Children on the same level are called siblings (brothers
or sisters).
XML tags are case-sensitive:
<C6TY> <City> <city>
XML can abbreviate empty elements, for example:
<married> </married> can be abbreviated to
<married/>
6 lements({ont¶d)
ntity References
There are 5 predefined entity references in
XML:
6 lements
(cont¶d)
All elements must have an end tag.
All elements must be cleanly nested
(overlapping elements are not allowed).
6 ~ttributes
An attribute is a name-value pair
separated by an equal sign (=) and
attribute value must be in ³ ´.
Example:
<City Z6P=³94608´> Hyderabad </City>
Attributes are used to attach additional,
secondary information to an element.
ase of lements vs
~ttributes
ternal eclaration
({ont¶d)
Internal eclaration
6f the DTD is declared inside the XML file,
it should be wrapped in a DOCTYPE
definition with the following syntax:
<!DOCTYPE root-element [element-
declarations]>
ample:-
({ont¶d)
<?xml version="1.0"?>
<!DOCTYPE note [
<!ELEMENT note (to,from,heading,body)>
<!ELEMENT to (#PCDATA)>
<!ELEMENT from (#PCDATA)>
<!ELEMENT heading (#PCDATA)>
<!ELEMENT body (#PCDATA)>
]>
<note>
<to>Hari</to>
<from>Anupam</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend</body>
</note>
({ont¶d)
ternal eclaration
6f the DTD is declared in an external file, it
should be wrapped in a DOCTYPE
definition with the following syntax:
<!DOCTYPE root-element SYSTEM
"filename">
ample:-
({ont¶d)
<?xml version="1.0"?>
<!DOCTYPE note SYSTEM "note.dtd">
<note>
<to>Hari</to>
<from>Anupam</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
And this is the file "note.dtd" which contains the DTD:
<!ELEMENT note (to,from,heading,body)>
<!ELEMENT to (#PCDATA)>
<!ELEMENT from (#PCDATA)>
<!ELEMENT heading (#PCDATA)>
<!ELEMENT body (#PCDATA)>
(cont¶d)
Occurrence 6ndicator:
Indicator Occurrence