0% found this document useful (0 votes)
1 views14 pages

4..lect-09 XML Languages & Applications

Uploaded by

raza03338128273
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views14 pages

4..lect-09 XML Languages & Applications

Uploaded by

raza03338128273
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 14

XML LANGUAGES &

APPLICATIONS

eXtensible Markup
Language
(New generation of markup languages)
CORE XML
 XMLstands for EXtensible Markup
Language.
 XML was designed to describe data, not to
display data like HTML
 XML is a software- and hardware-independent

tool for carrying information.


 XML tags are not predefined. You must define

your own tags


 XML is designed to be self-descriptive

 XML is easy to learn.


XML DOCUMENT EXAMPLE
<?xml version="1.0" encoding="UTF-8"?>

<note>
<to>Mr. Saif</to>
<from>IQRA COLLEGE</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!
</body>
</note>
DIFFERENCE B/W XML &
HTML
 XML is not a replacement for HTML.
 XML and HTML were designed with

different goals:
XML was designed to describe data, with
focus on what data is
HTML was designed to display data, with
focus on how data looks
 HTML is about displaying information,
while XML is about carrying
information.
DIFFERENCE B/W XML &
HTML
With XML You Invent Your Own Tags:
 The tags in the example above (like <to>

and <from>) are not defined in any XML


standard.
 These tags are "invented" by the author of

the XML document.


 That is because the XML language has no

predefined tags.
 The tags used in HTML are predefined.

 HTML documents can only use tags defined

in the HTML standard (like <p>, <h1>, etc.).


 XML allows the author to define his/her own

tags and his/her own document structure.


HOW CAN XML BE USED?
XML Separates Data from HTML:
 If you need to display dynamic data in your

HTML document, it will take a lot of work to


edit the HTML each time the data changes.
 With XML, data can be stored in separate

XML files. This way you can concentrate on


using HTML/CSS for display and layout, and
be sure that changes in the underlying data
will not require any changes to the HTML.
 With a few lines of JavaScript code, you can

read an external XML file and update the


data content of your web page.
HOW CAN XML BE USED?
XML Simplifies Data Sharing :
 In the real world, computer systems and

databases contain data in incompatible


formats.
 XML data is stored in plain text format.

 This provides a software- and hardware-

independent way of storing data.


 This makes it much easier to create data that

can be shared by different applications.


XML Simplifies Data Transport
 Exchanging data as XML greatly reduces this

complexity, since the data can be read by


different incompatible applications.
HOW CAN XML BE USED?
XML Simplifies Platform Changes
 Upgrading to new systems (hardware or

software platforms), is always time consuming.


 Large amounts of data must be converted and

incompatible data is often lost.


 XML data is stored in text format. This makes

it easier to expand or upgrade to new


operating systems, new applications, or new
browsers, without losing data.
Internet Languages Written in XML:
 Several Internet languages are written in XML.

Here are some examples:


 XHTML , XML Schema, XSL, WSDL, RSS
XML TREE:
 XML documents form a tree structure that starts at
"the root" and branches to "the leaves".
 The first line is the XML declaration. It defines the

XML version:
 <?xml version="1.0" encoding="UTF-8"?>
 The next line describes the root element of the
document: <Note>
 The next 4 lines describe 4 child elements of the

root: (to, from, heading, and body):


 <to>Tove</to>
 <from>Jani</from>
 <heading>Reminder</heading>
 <body>Don't forget me this weekend!</body>
 And finally the last line defines the end of the
root element: </Note>
XML TREE:
XML Documents Form a Tree Structure:
 XML documents must contain a root element. This element

is "the parent" of all other elements. The elements in an


XML document form a document tree. The tree starts at
the root and branches to the lowest level of the tree. All
elements can have sub elements (child elements):
<root>
<child>
<subchild>.....</subchild>
</child>
</root>
 The terms parent, child, and sibling are used to describe

the relationships between elements. Parent elements have


children. Children on the same level are called siblings
(brothers or sisters). All elements can have text content
and attributes (just like in HTML).
XML Documents Form a Tree Structure:
 Example:
 <bookstore> //Root
 <book category="COOKING"> //Child
 <title lang="en">Everyday Italian</title> // Sub-child
 <author>Giada De Laurentiis</author>
 <year>2005</year>
 <price>30.00</price>
 </book>
 <book category="CHILDREN"> // Sibling
 <title lang="en">Harry Potter</title>
 <author>J K. Rowling</author>
 <year>2005</year>
 <price>29.99</price>
 </book>
 <book category="WEB"> // Sibling
 <title lang="en">Learning XML</title>
 <author>Erik T. Ray</author>
 <year>2003</year>
 <price>39.95</price>
 </book>

XML SYNTAX RULES
(01) All XML Elements Must Have a Closing Tag:
 In HTML, some elements do not have to have a closing

tag:
<p>This is a paragraph. <br>
 In XML, it is illegal to omit the closing tag. All elements

must have a closing tag:


<p>This is a paragraph.</p>
<br /> [XML syntax to write tag of no contain]
(02) XML Tags are Case Sensitive:
 XML tags are case sensitive. The tag <Letter> is

different from the tag <letter>.


 Opening and closing tags must be written with the same

case:
<Message>This is incorrect</message>
<message>This is correct</message>
(03) Entity References:
 Some characters have a special meaning in XML. If

you place a character like "<" inside an XML


element, it will generate an error because the
parser interprets it as the start of a new element.
 This will generate an XML error:

<message>if salary < 1000


then</message>
 To avoid this error, replace the "<" character with

an entity reference:
<message>if
Entity Refs.
salary
Symbol
&lt; 1000
Meaning
then</message>
&lt; < Less than
&gt; > Greater than
&amp; & Ampersand
&apos; ‘ Apostrophe
&quot; “ Quotation mark
XML SYNTAX RULES
(04) XML Elements Must be Properly Nested:
 In HTML, you might see improperly nested

elements:
<b><i>This text is bold and italic</b></i>
 In XML, all elements must be properly nested

within each other:


<b><i>This text is bold and italic</i></b>
(05) XML Attribute Values Must be Quoted:
 XML elements can have attributes in name/value

pairs just like in HTML.


 In XML, the attribute values must always be

quoted.
 Study the two XML documents
1st One: 2nd One: below. The first one
is <note
incorrect, the second<note
date=12/11/2007> is correct:
date=“12/11/2007”>
<to>Tove</to> <to>Tove</to>
<from> Jani </form> <from> Jani </form>

You might also like