Ajax combat: Generating XML data for clients

Source: Internet
Author: User
Tags php and php and mysql

Listing 3-5 shows a quick and rough [13] solution to achieve this particular requirement. This example uses PHP and MySQL databases, but our focus is on the overall structure. If you change to ASP, JSP, or Ruby script, you may get code that is similar in structure.

Code listing 3-5 generates XML data streams quickly and with the result of database query results

The PHP page in Listing 3-5 generates an XML page similar to code listing 3-6, in which there are two matching products in the database. Here, the code is indented to make it easier to read. XML is chosen as the medium of communication between the client and the server because it is usually used for this purpose, and the 2nd chapter also mentions how to use the Xml-httprequest object to process the server-side generated XML document. The 5th chapter will explore the other options for client and server communication in more detail.

Code Listing 3-6 Code listing 3-5 output Simple XML

We have a Web server-side application that assumes a good AJAX application at the front end to handle this XML. To look forward to the future. Let's say you want to add subcategories (such as fashion, casual wear, outdoor sportswear) as the product range expands, add the "season Search" feature, implement keyword search, and clear links to entries. All of these features can be well supported by similar XML data streams. Let's look at how to reuse the current code to achieve these goals and what obstacles will be encountered in the process.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.