JavaScript
  Home arrow JavaScript arrow Page 4 - Fetching XML Data from the Server for an A...
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 
Sun Developer Network 
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

Fetching XML Data from the Server for an AJAX Headlines System
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 5
    2006-09-26

    Table of Contents:
  • Fetching XML Data from the Server for an AJAX Headlines System
  • A brief look back at the client-side code
  • Listing the complete client-side code of the application
  • Creating an XML file for storing data

  • 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


    Fetching XML Data from the Server for an AJAX Headlines System - Creating an XML file for storing data


    (Page 4 of 4 )

    Admittedly, the headlines application would be rather incomplete if I didn’t show you the corresponding XML file, which is useful for storing, in a well-structured fashion, all the headlines, images and links that will be displayed on the pertinent web page.

    Since the XML file in question is requested in the background the first time the web document is loaded, and additionally must be capable of maintaining all the data accommodated in a correct way, below I coded a basic version of it called “headlines.xml.” It can be easily modified to suit more specific requirements. Have a look at it, please:

    <?xml version="1.0" encoding="iso-8859-1"?>
    <headlines>
    <headline>
    <image>image1.jpg</image>
    <url>Link for headline 1 goes here</url>
    <text>Text for headline 1 goes here</text>
    </headline>
    <headline>
    <image>image2.jpg</image>
    <url>Link for headline 2 goes here</url>
    <text>Text for headline 2 goes here</text>
    </headline>
    <headline>
    <image>image3.jpg</image>
    <url>Link for headline 3 goes here</url>
    <text>Text for headline 3 goes here</text>
    </headline>
    <headline>
    <image>image4.jpg</image>
    <url>Link for headline 4 goes here</url>
    <text>Text for headline 4 goes here</text>
    </headline>
    <headline>
    <image>image5.jpg</image>
    <url>Link for headline 5 goes here</url>
    <text>Text for headline 5 goes here</text>
    </headline>
    <headline>
    <image>image6.jpg</image>
    <url>Link for headline 6 goes here</url>
    <text>Text for headline 6 goes here</text>
    </headline>
    <headline>
    <image>image7.jpg</image>
    <url>Link for headline 7 goes here</url>
    <text>Text for headline 7 goes here</text>
    </headline>
    <headline>
    <image>image8.jpg</image>
    <url>Link for headline 8 goes here</url>
    <text>Text for headline 8 goes here</text>
    </headline>
    <headline>
    <image>image9.jpg</image>
    <url>Link for headline 9 goes here</url>
    <text>Text for headline 9 goes here</text>
    </headline>
    <headline>
    <image>image10.jpg</image>
    <url>Link for headline 10 goes here</url>
    <text>Text for headline 10 goes here</text>
    </headline>
    </headlines>

    As you can appreciate, the structure that I provided to the above XML file is very simple to grasp. In short, all I did concerning this file was define a pair of <headline> tags for each of the headlines to be displayed, which wrap up a few child nodes composed of the <image>, <url> and <text> tags respectively.

    For this example, I decided to code exactly ten <headline> entries, but as I explained before, this structure can be easily altered to fit different demands. After all, creating the appropriate XML file that feeds this AJAX-driven application wasn’t hard at all, was it?

    Final thoughts

    In this two-part series, I went through the development of a small yet highly expansible AJAX application that can be used for displaying a predefined number of headlines, in addition to their associated images and links.

    As you saw here, the core modules can be easily tweaked with minor hassles. You might choose to do so if you are using a database table instead of an XML data file. Even the programming logic can be changed to request each headline separately. Indeed, the possibilities are numerous and exciting.

    As usual, see you in the next web development article!  


    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

       · In this concluding part of the series, you'll learn how to code a simple XML file...
     

    JAVASCRIPT ARTICLES

    - More on JavaScript Array Objects
    - Methods of the DOM Location Object
    - The DOM Location Object Properties
    - Handling Remote Files with JavaScript Click ...
    - Using Click Interceptions with a Database-Dr...
    - Using JavaScript Click Interceptions in an I...
    - Using Click Interceptions with JavaScript
    - QuickSort in Action
    - Quicksort
    - Using Mod_Security to Protect Your Server
    - Detecting and Countering Server Intrusions
    - Securing Your Web Server
    - Building a Secure Web Server
    - Protecting the Server
    - Book Review: Learning the Yahoo! User Interf...


     
    Best Practices for Windows Vista Migration Presentation
    Dell and Microsoft recently held a series of face-to-face seminars entitled, &qu....

     
    Creating a Culture for Code Reuse
    If you oversee development teams you know that like it or not proprietary and ex....

     
    Keys to Web Application Acceleration: Advances in Delivery Systems
    Accelerate Web apps by up to 5x. Ensure significantly faster access to the Web a....

     
    Optimizing Application Monitoring
    Tired of finding out from your customers that you're offline? This white paper e....

     
    Solaris to Solaris Migration -- Migrating applications from Sun SPARC to Dell PowerEdge R900
    This comprehensive Migration Guide reviews the approach that Principled Technolo....

     





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