JavaScript Remote Scripting: Processing XML Files
(Page 1 of 6 )
In this article, you will learn how to use AJAX for reading and manipulating simple XML files, in order to implement a basic Web service. Specifically, you will learn how to develop a JavaScript application that fetches data from an XML file. By the end of this article, you will know the basics for using client-side parsed XML in your own applications.
Here you have it. Welcome to the second part of the series “JavaScript Remote Scripting.” Based on the theoretical concepts explained in the first tutorial, as well as their application in an illustrative example, I’ve demonstrated how to read file data from the server by using AJAX as the primary method for making http requests in the background, without having to reload the current page.
Stepping back for a moment to the script that I previously developed in the first article, it implements a simple mechanism for fetching data from a plain text file and displaying the information through a predefined sequence. Although the example is rather basic, it does exposes the foundations of AJAX technology for building more complex and polished applications, by utilizing as core programming logic the powerful capabilities for sending silent http requests on the fly.
The best thing with this approach is that it offers a broad range of applications for fetching data from the server in multiple formats. Of course you have already seen how easy it is to fetch data from flat text files and display their contents directly on the browser, all without messing up things too much with complex server-side programs. Moreover, AJAX comes with native support for pulling out data served as XML, by using the “responseXML” property that belongs to the XMLHtttpRequest object.
Considering that XML is today one of the most common data carriers used when working with Web services, this second part of the series will put strong attention to developing a JavaScript application that fetches data from an XML file, by taking advantage of the native capabilities that AJAX brings to developers for working with this markup language. In my attempt to illustrate the relevant role of AJAX within the area of remote scripting, by the end of this article you will know the basics for using client-side parsed XML in your own applications.
Now that you know the objectives of this second part of the series, it’s time to move on to learn more about JavaScript-based XML processing. Let’s get going!
Next: XML in the client: the basics of AJAX XML processing >>
More JavaScript Articles
More By Alejandro Gervasio