Error Management

If you try to replace the method you are calling with any method you did not implement, the service will automatically trigger an error, which will be caught by the client and can be checked via the faultCode method. So if we change one line in the client script to message new XML_RPC_Message 'label.getArtists', params Could not use the XML-RPC service. Unknown method As we did not implement the method, the service will signal the error automatically without any intervention needed by the...

Mapping XML to Objects

By default, XML_Unserializer will convert complex XML structures i.e. every tag that contains nested tags or attributes to an associative array. This behavior can be changed by setting the following option 'object' If you add this line of code to the script, the output will be changed includes gt usr share php myapp templates gt var www skins myapp the other sections have been left out Instead of associative arrays, XML_Unserializer will create an instance of the stdClass class, which is always...

Creating the XML Document from the Object Tree

As you are now familiar with XML_Serializer, let us go back to the initial task we need to accomplish and create an XML document from the objects we instantiated that contained information about record labels, artists, and their recorded albums. As XML_Serializer accepts any PHP variable as input for the XML document, the easiest way to start this task is just passing the labels variable, which contains one or more Label objects. Additionally we set some options that we are already sure of...

Adding Formulas

Creating formulas and assigning them to cells is one of the basic functions of Excel. Now that we can add and format data in our spreadsheet we can add a couple of formulas to make Excel do the work for us. require_once 'Spreadsheet Excel Writer.php' workbook new tax amp workbook- gt addFormat tax- gt setNumFormat '.00 ' price amp workbook- gt addFormat worksheet- gt write 0, 0, 'Tax Calculation Worksheet' tax Tax worksheet- gt write i, 0, Item i worksheet- gt write i, 1, rand 3, 100 , price...

Parsing RSS with XMLRSS

RSS is an acronym that refers to the following three terms As the last term implies, RSS is used for syndication of the content, so you can offer other websites and clients access to your content or include third-party content in your website. RSS is commonly used by web logs and news aggregators. As RSS is an XML application, you may use any of the previously covered packages, but PEAR provides a package that is aimed only at extracting information from any RSS document and which makes working...

Filtering Results

Some methods introduced in the previous section provided information about multiple holidays by using arrays as return values. By default, a driver returns information about all holidays it knows. Sometimes this is more information than you need. To enable you to restrict the amount of returned data, these methods allow the use of filters. A filter is an object that contains internal names of holidays. When you pass it to functions that return a list array of holidays as result, it decides...

Multiple Worksheets Borders and Images

Now that the hard stuff is out of the way, we can return to making our spreadsheet look nice. To illustrate the use of formats, we will create a simple Invoice generator. For the sake of brevity we have excluded a lot of formats, so further beautification is left as an exercise for the reader. require_once 'Spreadsheet Excel Writer.php' workbook new worksheet amp workbook- gt addWorksheet worksheet- gt writeNote 1, 0, Invoice For New Customer worksheet- gt setRow 0, 50 worksheet- gt...

Creating XML Documents with XMLSerializer

While XML_Serializer is a package for creating XML documents, it takes a totally different approach from the last two packages, XML_Util and XML_FastCreate. When working with one of these packages, you are creating the document tag by tag with each method call. When using XML_Serializer, you are calling one method to create the complete document at once. It will extract the raw information from an array or an object and convert it to an XML document. While this may sound inflexible, when...