Web Tech Class 5
-
Upload
jakaltarget -
Category
Documents
-
view
217 -
download
0
Transcript of Web Tech Class 5
-
8/8/2019 Web Tech Class 5
1/13
Mr. Debojit Boro
Assistant Professor,Tezpur University,Napaam,Tezpur-784028
Web Technology
Batches:
M.Tech. 2nd Semester
B.Tech 6th Semester
B.Tech. 8th Semester
MCA 4th Semester
B.Tech. Electronics 8th Semester
-
8/8/2019 Web Tech Class 5
2/13
Topics for today
XML HTTP Request
XML Parser
Mr. Debojit Boro
Assistant Professor,Tezpur University,Napaam,Tezpur-784028
-
8/8/2019 Web Tech Class 5
3/13
XMLHttpRequest
XMLHttpRequest is used to communicatewith your server from inside a web page.
Update a web page with new data withoutreloading the page
Request and receive new data from a server
after the page has loaded Communicate with a server in the
background
-
8/8/2019 Web Tech Class 5
4/13
Creation of XMLHttpRequest
var xmlhttp=new XMLHttpRequest()
Or in IE 5 or 6
var xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
-
8/8/2019 Web Tech Class 5
5/13
XML Parsing
Two approaches forXML Parsing
XML Doc
SAXApproach
DOM Approach
String of Elements
Tree Like Structure
-
8/8/2019 Web Tech Class 5
6/13
Everyday Italian
Giada De Laurentiis
2005
30.00
XML Document
SAX (Simple API for XML) ll look like
StartElement:bookstore
StartElement:book
StartElement:title
Characters: Everyday Italian
EndElement:title
-
8/8/2019 Web Tech Class 5
7/13
Sequential Approach(SAX) also
know as Simple API for XML
It is an incremental approach
Signals the application program about the
start and end of elements
Deals with only single element at a time
Considers data to be made up of string of
elements
It concentrate just on the current and not onthe XML Document in totality
-
8/8/2019 Web Tech Class 5
8/13
Document Object Model(DOM)
This approach treats the XML Document as
a tree like structure
Loads the entire XML document into the
memory Compiles the XML Doc into an internal tree
Converts the elements and attributes into
nodes of the tree
-
8/8/2019 Web Tech Class 5
9/13
XML Parser
The XML DOM contains methods (functions)to traverse XML trees, access, insert, anddelete nodes.
However, before an XML document can beaccessed and manipulated, it must be loadedinto an XML DOM object.
An XML parser reads XML, and converts it
into anX
ML DOM object that can beaccessed with JavaScript.
Most browsers have a built-in XML parser.
-
8/8/2019 Web Tech Class 5
10/13
if (window.XMLHttpRequest) {
xhttp=new XMLHttpRequest();
}
else // for older IE 5/6
{
xhttp=new ActiveXObject("Microsoft.XMLHTTP");
} xhttp.open("GET","books.xml",false);
xhttp.send("");
xmlDoc=xhttp.responseXML;
document.write("XML document loaded into an XML DOM Object.");
Code for loading of XML Document
-
8/8/2019 Web Tech Class 5
11/13
XML VS HTML
XML and HTML are not alternative to each other
They are complement to each other
HTML is for presentation
XML for meaningful encoding
To display an XML document we have to transform to HTML
XHTML is the XML version of HTML
If we display raw XML document we may get only a tree view
Tree View XML Example
We can display an XML document with CSS Example with css
We can also display by transforming XML to HTML by XSL
-
8/8/2019 Web Tech Class 5
12/13
XML Transformation
XML document can be transformed to another
XML document or to HTML XML content needs to be transformed to HTML
if we want the content to be displayed by the
browser
XSL (eXtensible Stylesheet Language) capturesthe rues of transformation
XSL also follows XML syntax
In the XML file include this reference
-
8/8/2019 Web Tech Class 5
13/13
Classwork
Create an XML document that describes your details in the following
hierarchy
Name LastName
FirstName
MiddleName
Age Years
Months
Address Country
State
CityPin
Phone Country code
Area code
Phone number