Book Image

Practical Web Development

By : Paul Wellens
Book Image

Practical Web Development

By: Paul Wellens

Overview of this book

Table of Contents (23 chapters)
Practical Web Development
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
10
XML and JSON
Index

Chapter 10. XML and JSON

So far, we have been using HTML everywhere. It is the format for web pages, so we have used it to create static web pages. As a consequence, HTML is the format of the data that is exchanged between the server and the client during the page load of the .html file.

When we create web pages dynamically, our PHP code will compose lines of HTML by the time data is sent across, which will be the true data that is exchanged, not the original content of your .php file. When we used Ajax, we did not specify a data format as a parameter in our jQuery Ajax methods, .post() or .ajax(), because it was implicitly understood that it would be HTML.

In this chapter, we introduce two different data formats, XML and JSON. In web development, we can use them in different ways. First, they can be an alternative to your database. For simple projects, your data can be stored in a text file, rather than in a full blown database. You could even store it as plain text.

The next, and better,...