Skip to Content
PHP Cookbook, 3rd Edition
book

PHP Cookbook, 3rd Edition

by David Sklar, Adam Trachtenberg
July 2014
Intermediate to advanced
820 pages
17h 6m
English
O'Reilly Media, Inc.
Content preview from PHP Cookbook, 3rd Edition

Chapter 12. XML

Introduction

XML is a popular data-exchange, configuration, and message-passing format. Although JSON has displaced XML for many basic situations, XML still plays an important role in a developer’s life. With the help of a few extensions, PHP lets you read and write XML for every occasion.

XML provides developers with a structured way to mark up data with tags arranged in a tree-like hierarchy. One perspective on XML is to treat it as CSV on steroids. You can use XML to store records broken into a series of fields. But instead of merely separating each field with a comma, you can include a field name, a type, and attributes alongside the data.

Another view of XML is as a document representation language. For instance, this book was written using XML. The book is divided into chapters; each chapter into recipes; and each recipe into Problem, Solution, and Discussion sections. Within any individual section, we further subdivide the text into paragraphs, tables, figures, and examples. An article on a web page can similarly be divided into the page title and headline, the authors of the piece, the story itself, and any sidebars, related links, and additional content.

XML content looks similar to HTML. Both use tags bracketed by < and > for marking up text. But XML is both stricter and looser than HTML. It’s stricter because all container tags must be properly closed. No opening elements are allowed without a corresponding closing tag. It’s looser because you’re not forced ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

PHP Cookbook, 2nd Edition

PHP Cookbook, 2nd Edition

Adam Trachtenberg, David Sklar
Programming PHP, 4th Edition

Programming PHP, 4th Edition

Kevin Tatroe, Peter MacIntyre
MySQL Cookbook, 4th Edition

MySQL Cookbook, 4th Edition

Sveta Smirnova, Alkin Tezuysal

Publisher Resources

ISBN: 9781449363741Errata