XML, the Extensible Markup Language, is a standardized data format.
It looks a little like HTML, with tags (
<example>like this</example>) and
&). Unlike HTML,
however, XML is designed to be easy to programmatically parse, and there are
rules for what you can and cannot do in an XML document. XML is now the
standard data format in fields as diverse as publishing, engineering, and
medicine. It’s used for remote procedure calls, databases, purchase orders,
and much more.
There are many scenarios where you might want to use XML. Because it is a common format for data transfer, other programs can emit XML files for you to either extract information from (parse) or display in HTML (transform). This chapter shows you how to use the XML parser bundled with PHP, as well as how to use the optional XSLT extension to transform XML. We also briefly cover generating XML.
Recently, XML has been used in remote procedure calls (XML-RPC). A client encodes a function name and parameter values in XML and sends them via HTTP to a server. The server decodes the function name and values, decides what to do, and returns a response value encoded in XML. XML-RPC has proved a useful way to integrate application components written in different languages. We’ll show you how to write XML-RPC servers and clients in Chapter 15, but for now let’s look at the basics of XML.