• Tidak ada hasil yang ditemukan

XML and AJAX

N/A
N/A
Protected

Academic year: 2024

Membagikan "XML and AJAX"

Copied!
49
0
0

Teks penuh

(1)
(2)

What is XML?

XML stands for EXtensible Markup Language.

XML is a markup language much like HTML.

XML was designed to store and transport data.

XML was designed to be self-descriptive

(3)

XML Example 1

This note is a note to Tove, from Jani, stored as XML:

(4)

XML and HTML were designed with different goals:

XML was designed to carry data - with focus on what data is

HTML was designed to display data - with focus on how data looks

XML tags are not predefined like HTML tags .

The Difference Between XML and HTML

(5)

XML Does Not Use Predefined Tags

The XML language has no predefined 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.

HTML works with predefined tags like <p>, <h1>, <table>, etc.

With XML, the author must define both the tags and the document structure.

(6)

XML does not carry any information about how to be displayed.

The same XML data can be used in many different presentation scenarios.

Because of this, with XML, there is a full separation between data and presentation.

XML Separates Data from Presentation

(7)

XML Example 2

(8)
(9)
(10)

XML Tree Structure

(11)

XML Tree Structure

XML documents are formed as element trees.

An XML tree starts at a root element and branches from the root to child elements.

All elements can have sub elements (child elements):

(12)

XML Syntax Rules

The syntax rules of XML are very simple and logical.

The rules are easy to learn, and easy to use.

(13)

XML Documents Must Have a Root Element

XML documents must contain one root element that is the parent of all other elements:

(14)

The XML Prolog

This line is called the XML prolog:

The XML prolog is optional. If it exists, it must come first in the document.

XML documents can contain international characters, like Norwegian øæå or French êèé.

To avoid errors, you should specify the encoding used, or save your XML files as UTF-8.

UTF-8 is the default character encoding for XML documents.

(15)

All XML Elements Must Have a Closing Tag

(16)

XML Tags are Case Sensitive

(17)

XML Elements Must be Properly Nested

(18)

XML Attribute Values Must be Quoted

(19)

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:

(20)
(21)

Comments in XML

(22)

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:

text

attributes

other elements

or a mix of the above

(23)
(24)

Empty XML Elements

(25)

XML Naming Rules

XML elements must follow these naming rules:

Element names are case-sensitive .

Element names must start with a letter or underscore.

Element names cannot start with the letters xml (or XML, or Xml, etc).

Element names can contain letters, digits, hyphens, underscores, and periods.

Element names cannot contain spaces.

(26)

XML Attributes

XML elements can have attributes, just like HTML.

Attributes are designed to contain data related to a specific element.

(27)

XML Attributes Must be Quoted

(28)

XML Elements vs. Attributes

(29)

My Favorite Way

(30)
(31)
(32)

AJAX

(33)

What is AJAX?

AJAX = Asynchronous JavaScript and XML.

AJAX is a technique for creating fast and dynamic web pages.

AJAX allows web pages to be updated asynchronously by exchanging small amounts of data with the server behind the scenes. This means that it is possible to update parts of a web page, without reloading the whole page.

Classic web pages, (which do not use AJAX) must reload the entire page if the content should change.

Examples of applications using AJAX: Google Maps, Gmail, YouTube, and Facebook.

(34)

How AJAX Works

Requestي

Responsي

e

(35)

The XMLHttp Request Object

All modern browsers support the XMLHttp Request object.

The XMLHttp Request object is used to exchange data with a server behind the scenes. This means that it is possible to update parts of a web page, without

reloading the whole page.

(36)

Create an XMLHttpRequest Object

(37)

Example :

(38)

AJAX - Send a Request To a Server

The XMLHttpRequest object is used to exchange data with a server.

(39)

The XMLHttpRequest object is used to exchange data

with a server.

(40)

GET or POST?

GET is simpler and faster than POST, and can be used in most cases.

However, always use POST requests when:

A cached file is not an option (update a file or database on the server).

Sending a large amount of data to the server (POST has no size limitations).

Sending user input (which can contain unknown characters), POST is more robust and secure than GET.

(41)

The url - A File On a Server

(42)

Asynchronous - True or False?

With AJAX, the JavaScript does not have to wait for the server response, but can instead:

execute other scripts while waiting for server response

deal with the response when the response ready

(43)

Async=true

(44)

Async=false

(45)

AJAX - Server Response

(46)

The responseText Property

(47)

The onreadystatechange event

When a request to a server is sent, we want to perform some actions based on the response.

The onreadystatechange event is triggered every time the readyState changes.

The readyState property holds the status of the XMLHttpRequest.

(48)

Three important properties of the

XMLHttpRequest object:

(49)

Example

Referensi

Dokumen terkait

The UN’s Sustainable Development Goals (SDGs) were designed to help society and business to focus on solving global sustainability challenges.. As a key stakeholder, the

Autograph is the most popular software for teaching secondary and college level mathematics. Autograph was designed by teachers, and stands alone with its strong focus

This research work was embarked on to show the business value of big data analytics in Energy and utilities with a focus on how analytics can help solve problems of

Many conservation initiatives are based in the 2003 “Indonesian Biodiversity Strategy and Action Plan IBSAP” that was developed with a focus on achieving five goals: 1 to encourage

 HTML tag with no matching close tag  HTML tag with inline CSS  HTML tag with correct condition The above data are reassembled into new HTML files having the same name based on

This paper looks at the cultural aspects of migration that drive labor migrants to South Africa, with a focus on the Indian business district in Johannesburg, Fordsburg, and the flea

The specific objectives of the study were: a to carry out literature reviews on the various methodology and tools that are used to analyse complex systems, with a particular focus on

CWM Data Warehouse RDBMS OLAP Data Sources ETL Process Central Data Warehouse Architected Data Mart Applications Data Mart Data Mart DSS EIS GDSS XML Documents