Introduction to Server-Side XML

It sets the scene for server-side XML, and shows what you can do with it, by way of a parallel example done in ASP, PHP, and JSP (we have only included the first of the example sections here). The three chapters that follow this one in the book are case studies, which go into using XML with the three server-side languages mentioned above in much more detail.

This sample is taken from Chapter 8 "Introduction to Server-Side XML" of the glasshaus title "Practical XML for the Web".

Introduction To Server-Side XML

In this chapter, and the ones to follow, we'll switch from client-side to server-side XML processing. We'll start by examining why you would want to consider server-side processing, and then we'll introduce the three main server-side languages used in web development: ASP, JSP, and PHP.

We'll discuss the pros and cons of each, and then go through some simple XML processing techniques with short code examples from each language. By way of a running example, we'll show you how to maintain an online list of your favorite CDs, stored in XML format. You'll learn how to add new elements to the XML document, modify existing ones, and delete unwanted items. You'll also learn how to transform the XML to HTML.

We'll go through this step-by-step, showing you the code needed in all three languages, giving you a solid overview of basic server-side XML techniques.

The chapters that follow will then show you in-depth case studies for each of these languages.

Server-Side Versus Client-Side XML Processing

By now you're probably all excited about what's possible using client-side XML processing. So why would you want to learn about server-side techniques? Trust me, you do.

Server-side XML gives you even more power. For example, since the processing is done on the server, only the results are sent to the client, so you don't have to worry about making your code cross-browser compatible. It is true that processing XML on the server-side transfers some of the load to the server, but since web servers are usually extremely powerful creatures with the ability to cache data, that is probably nothing to be worried about.

In addition, the server-side approach also greatly reduces the amount of data that flows across the network connection. If you want to display different results for different browsers, then that is easily accomplished by detecting the browser-type on the server side and using the correct stylesheet for the transformation.

The following points sum up the advantages of server-side processing:

·          Systems can provide better performance and maintainability for data-driven web sites by generating and caching frequently accessed pages ahead of time on the server.

·          You can have direct control over the security of your data  sensitive information can be filtered out before sending the data to the client. For example (an extreme one), if we have an XML document that contains a list of users and passwords, there is a security risk involved in sending the whole XML document to the client to be transformed there  it would be better to filter the passwords out of the server side.

·          Maintaining your code becomes easier, since you don't have to modify it when new browser types or versions become available.

·          By doing transformations on the server side you can greatly simplify what is sent to the client, avoiding the problem of designing functionality that works for all possible browser combinations (even mobile devices).

XML support in browsers is still limited, so if you want to dispense with browser-compatibility issues and suchlike, I would recommend that you use client-side XML processing only when developing something like closed intranets where all clients use the same browser. Your safest bet is still usually server-side processing.

Before We Continue

This chapter contains code examples using ASP, PHP, and JSP. If you wish to try running these examples on your computer, then you need to install some software before you continue.

Detailed installation instructions for each language can be found online at http://www.glasshaus.com/.

Server-Side Languages

The server-side market is a crowded one. Developers can choose from a variety of languages  ASP, ColdFusion, JSP, Perl, PHP, and more. With such a wealth of options out there, determining which environment best suits your needs can be bewildering.

The choice of a server-side programming language is a constant source of heated debate. The languages can all pretty much achieve the same things, but there are differences in portability, scalability, performance, and learning curve.

In this section we'll cover the three biggest players in the server-side market: ASP, PHP, and JSP. We'll give you a very brief overview of the advantages and shortcomings of each platform, and an idea of the XML support they offer.


George Petrov

George PetrovGeorge Petrov is a renowned software writer and developer whose extensive skills brought numerous extensions, articles and knowledge to the DMXzone- the online community for professional Adobe Dreamweaver users. The most popular for its over high-quality Dreamweaver extensions and templates.

George is also the founder of Wappler.io - the most Advanced Web & App Builder

See All Postings From George Petrov >>

Comments

Be the first to write a comment

You must me logged in to write a comment.