JavaScript
  Home arrow JavaScript arrow Page 2 - JavaScript Remote Scripting: Processing XM...
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
JAVASCRIPT

JavaScript Remote Scripting: Processing XML Files
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 11
    2005-10-05

    Table of Contents:
  • JavaScript Remote Scripting: Processing XML Files
  • XML in the client: the basics of AJAX XML processing
  • Reading XML files with AJAX: defining the “sendRequest()” function
  • Checking the progress of a request: a quick look at the “stateChecker()” function
  • Displaying XML data: defining the “createDataContainer()” and “displayData()” functions
  • Putting the pieces together: listing the complete script

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    JavaScript Remote Scripting: Processing XML Files - XML in the client: the basics of AJAX XML processing


    (Page 2 of 6 )

    In addition to the “responseText” property that you saw in the first article, the XMLHttpRequest object offers the “responseXML” property, useful for processing server response, which has been sent back to the client as XML data. Using regular DOM methods, it’s possible to parse basically XML in the client and implement some kind of interaction, either for boosting the capabilities of user interfaces or the application layer itself.

    With reference to the above deployed concepts, in conjunction with the sample news rotator that I developed in part one of this series, what I’ll do next is write a simple script that retrieves some headlines from a XML file, then processes them and finally displays the results directly on the browser. Considering that client-side flat text file processing has already been covered, the next example will illustrate how to parse XML files once the corresponding http request has been successfully completed.

    As you might guess, in order to get the script parsing XML, first I’ll need to work with sample data served as XML. In this particular case, I’ll define a simple XML file, which contains some headlines to be included in the news rotator. Its definition is the following:

    <?xml version="1.0" encoding="iso-8859-1"?>
    <news>
    <message>
    <title>Learn advanced concepts about AJAX and Remote Scripting. Visit DevArticles.com now!</title>
    <url>http://www.devarticles.com</url>
    </message>
    <message>
    <title>PHP 5.1 now presents new key improvements such as PDO (PHP Data Objects)</title>
    <url>http://www.php.net</url>
    </message>
    <message>
    <title>Google to continue extending its GoogleMaps API</title>
    <url>http://www.google.com/apis/maps/documentation/</url>
    </message>
    <message>
    <title>MySQL releases Open Source Database Tools for Macintosh OS X</title>
    <url>http://www.mysql.com</url>
    </message>
    <message>
    <title>Release of Flash Player 8 allows to develop richer applications and communications</title>
    <url>http://www.macromedia.com</url>
    </message>
    <message>
    <title>PHP introduces more improvements in regards to SOAP, streams and SPL</title>
    <url>http://www.php.net</url>
    </message>
    </news>

    As you can see, the above listed XML file presents a simple structure for defining the appropriate headlines to be displayed, as well as the URLs tied to them. With reference to the document hierarchy, I’ve defined a general <news> tag, which is placed on top of the document tree, and then created a few <message> nodes to wrap up both <title> and <url> child elements. Of course neither style data nor element attributes have been defined for the document, thus its structure is very simple and understandable.

    Now that you have a pretty clear idea of how the sample XML file looks, I can move on to start writing the complete JavaScript application.

    More JavaScript Articles
    More By Alejandro Gervasio


       · This second part of the series goes through the development of a JavaScript...
       · HiPlease can any one help me to manage a stick up footer on the website for IE...
     

    JAVASCRIPT ARTICLES

    - Validating Digits and Dates with jQuery`s Va...
    - Validating Ranges, Emails, and URLs with jQu...
    - More Uses for the jQuery Tooltip Plug-in`s b...
    - Building Image-Based Tooltips with the jQuer...
    - Using the jQuery Tooltip Plug-in`s bodyHandl...
    - Using Rangelength, Min and Max with the Vali...
    - Using Minlength and Maxlength with the Valid...
    - Modifying Tooltip Coordinates with the jQuer...
    - Applying a Fade Out Effect with the jQuery T...
    - Tracking Mouse Movements with the jQuery Too...
    - Checking Online Forms with the Validator jQu...
    - Nested JavaScript Functions as Objects
    - The jQuery Tooltip Plug-in
    - Active Client Pages at the Server
    - ACP Tab Web Page







    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 6 Hosted by Hostway
    Stay green...Green IT