$Name = "Leon Atkinson";
$Email = "[email protected]";
$Residence = "Martinez";
$Info = array("Email", "Residence");
//print packet
print(wddx_serialize_vars("Name", $Info));
?>
XML
Although the functions in this section come last, they are among the most important
functions available. The extensible markup language, XML, has steadily grown in
popularity since being introduced in 1996. XML is a first cousin to HTML in that it, too,
is derived from SGML, a generalized markup language that is nearly 20 years old. Like
HTML, XML documents surround textual data with tags. Unlike HTML, XML can be
used to communicate any type of data. The best place to start learning about XML is its
home page at the W3C http://www.w3.org/XML/. Among the resources there,
you will find book recommendations.
The functions in this section wrap the Expat library developed by James Clark
http://www.jclark.com/xml/. This library is part of the PHP distribution, and its
purpose is parsing XML documents. These functions work differently from other PHP
extensions. A stream of data is fed to the parser. As complete parts of the data are
recognized, events are triggered. These parts are the tags and the data they surround. You
register the events with a handler, a function you write. You may specify FALSE for the
name of any handler, and those events will be ignored.
In order to avoid repeating large blocks of code, I've written one example that uses most
of the functions in this section. It's near the description of
xml_set_element_handler and Figure 14.5. You will always need to create a
parser. You will also want to create handlers for character data and starting and ending
tags. Some of the other handlers may not be of use in most applications. You can leave
them out, and that data will be ignored by the parser.
Figure 14-5. xml_set_element_handler.