Sunteți pe pagina 1din 16

Introduction to XML

And HTML Language

Anant manas
Computer Science Department
What is XML 2

• XML stands for eXtensible Markup


Language.
• A markup language is used to provide
information about a document.
• Tags are added to the document to provide
the extra information.
• HTML tags tell a browser how to display
the document.
• XML tags give a reader some idea what
some of the data means.
What is XML Used For? 3

• XML documents are used to transfer data from one


place to another often over the Internet.
• XML subsets are designed for particular
applications.
• It is used to send breaking news bulletins from one
web site to another.
• A number of fields have their own subsets. These
include chemistry, mathematics, and books
publishing.
• Most of these subsets are registered with the
W3Consortium and are available for anyone’s use.
Advantages of XML 4

• XML is text (Unicode) based.


• Takes up less space.
• Can be transmitted efficiently.
• One XML document can be displayed
differently in different media.
• Html, video, CD, DVD,
• You only have to change the XML document in
order to change all the rest.
• XML documents can be modularized. Parts
can be reused.
Example of an HTML Document 5

<html>
<head><title>Example</title></head.
<body>
<h1>This is an example of a page.</h1>
<h2>Some information goes here.</h2>
</body>
</html>
Example of an XML Document 6

<?xml version=“1.0”/>
<address>
<name>Alice Lee</name>
<email>alee@aol.com</email>
<phone>212-346-1234</phone>
<birthday>1985-03-22</birthday>
</address>
Difference Between HTML and
XML 7

• HTML tags have a fixed meaning and browsers


know what it is.
• XML tags are different for different
applications, and users know what they mean.
• HTML tags are used for display.
• XML tags are used to describe documents and
data.
XML Rules 8

• Tags are enclosed in angle brackets.


• Tags come in pairs with start-tags and end-
tags.
• Tags must be properly nested.
• <name><email>…</name></email> is not allowed.
• <name><email>…</email><name> is.
• Tags that do not have end-tags must be
terminated by a ‘/’.
• <br /> is an html example.
More XML Rules 9

• Tags are case sensitive.


• <address> is not the same as <Address>
• XML in any combination of cases is not
allowed as part of a tag.
• Tags may not contain ‘<‘ or ‘&’.
• Tags follow Java naming conventions,
except that a single colon and other
characters are allowed. They must begin
with a letter and may not contain white
space.
• Documents must have a single root tag that
begins the document.
Introduction to HTML 10
HTML: HyperText Markup
Language 11

• HTML documents are simply text documents


with a specific form
• Documents comprised of content and markup tags
• Content: actual information being conveyed
• The markup tags tell the Web browser how to
display the page
• An HTML file must have an htm or html file
extension
• An HTML file can be created using a simple text
editor
Our First Example 12

• If you are running Windows, start Notepad


• If you are on a Mac, start SimpleText
• Type in the following:
<html>
<head>
<title>Title of page</title>
</head>
<body>
This is my first homepage. <b>This text is bold</b>
</body>
</html>
• Open this file using a browser.
HTML Tags 13

• HTML tags are used to mark-up HTML elements


• Surrounded by angle brackets < and >
• HTML tags normally come in pairs, like <tagname>
(start tag) and </tagname> (end tag)
• The text between the start and end tags is the
element content
• Not case-sensitive
• Follow the latest web standards:
• Use lowercase tags
Tag Attributes 14

• Tags can have attributes that provide


additional information to an HTML element
• Attributes always come in name/value pairs like:
name=“value”
• Attributes are always specified in the start tag
• Attribute values should always be enclosed in
quotes. Double quotes are most common.
• Also case-insensitive: however, lowercase is
recommended
• <tagname a1=“v1” a2=“v2”></tagname>
• For example, <table border=“0”> is a start tag that
defines a table that has no borders
HTML Document Structure 15

• Entire document enclosed within <html> and


</html> tags
• Two subparts:
• Head
• Enclosed within <head> and </head>
• Within the head, more tags can be used to specify
title of the page, meta-information, etc.
• Body
• Enclosed within <body> and </body>
• Within the body, content is to be displayed
• Other tags can be embedded in the body
“Thank You”

S-ar putea să vă placă și