HOME

XML Basic
XML HOME
XML Introduction
XML How to use
XML Syntax
XML Elements
XML Attributes
XML Validation
XML Browsers
XML Viewing
XML CSS Display
XML XSL Display
XML Data Islands
XML Parser
XML in Real Life

XML Advanced
XML Namespaces
XML CDATA
XML Encoding
XML Server
XML Applications
XML HTTP
XML Behaviors
XML Technologies

Examples/Quiz
XML Examples
XML Quiz


XML WebRing
Previous 5 Sites
Previous Site
Next Site
Next 5 Sites
Random Site
List Sites

Please visit our sponsors !

XML HTTP Requests

back next

If you are using IE 5.0 or higher, XML data can be requested from a server using an HTTP request.


The Browser Request

An HTTP request from the browser, can request XML from a server:

var objHTTP = new ActiveXObject("Microsoft.XMLHTTP")
objHTTP.Open('GET','httprequest.asp',false)
objHTTP.Send()

To view the result from the request, you can display the result in your browser:

document.all['A1'].innerText= objHTTP.status
document.all['A2'].innerText= objHTTP.statusText
document.all['A3'].innerText= objHTTP.responseText

Try it Yourself using JavaScript

Try it Yourself using VBScript


Communicating with the Server

With HTTP requests you can "communicate" with a server.

Communicating with a server using XML

In the example the response is "faked" on the server with this ASP code:

<%
response.ContentType="text/xml"
txt="<answer><text>12 Years</text></answer>"
response.write(txt)
%>

So, the answer will always be 12 years, no matter what question is asked. In real life, you have to write some code to analyze the question and respond with a correct answer.


back next

Jump to: Top of Page or HOME or Printer Friendly Printer friendly page


Search W3Schools:


What Others Say About Us

Does the world know about us? Check out these places:

Dogpile Alta Vista MSN Google Excite Lycos Yahoo Ask Jeeves


We Help You For Free. You Can Help Us!


W3Schools is for training only. We do not warrant its correctness or its fitness for use. The risk of using it remains entirely with the user. While using this site, you agree to have read and accepted our terms of use and privacy policy.

Copyright 1999-2002 by Refsnes Data. All Rights Reserved


Validate How we converted to XHTML Validate

ASPHits
Active Server Pages Resource Web Site


Your own Web Site?

Read W3Schools
Hosting Tutorial



$15 Domain Name
Registration
Save $20 / year!



Advertise
at W3Schools

Only 0.5 CPM



SELECTED LINKS

University Online
Master Degree
Bachelor Degree


Web Software

The Future of
Web Development


Jobs and Careers

Web Security
Web Statistics
Web Standards


PARTNERS

W3Schools
TopXML
VisualBuilder
XMLPitstop
DevelopersDex
DevGuru
Programmers Heaven
The Code Project
Tek Tips Forum
ZVON.ORG
TopXML Search