XML Workshop Continued

Avatar von Björn Schotte

The second part of the XML workshop continued with xmlReader (which will be part with PHP 5.1) and xmlWriter (which could be part of the upcoming standard PHP5.1 distribution). xmlWriter adds some handy functions to create well-formed documents with ease to use.

A small, but useful feature from the new DOM extension: it can „repair“ broken XML documents, i.e. adding closing XML tags when they are missing. It’s like HTMLTidy, but for XML.

Tobias continued with a longer marketi^Woverview of PEAR itself, from HowTo install PEAR, how to throw PEAR errors etc. and stepped over to give an introduction about some PEAR packages dedicated to XML.

He steps through some examples with XML_Util and follows with XML_Serializer which serializes PHP data structures like scalars, arrays and objects into XML format and is able to unserialize the XML. If you just want to transport data structures you could also use the built-in WDDX extension, but as Stephan Schmidt explains XML_Serializer can do more: within Services_EBay he only needed 10 lines of code to create the XML EBay expected within the XML_Serializer from an object structure.

Tobias introduced XML_FastCreate where you can basically create (X)HTML out of method calls like $x->html($x->body($x->p(‚foobar‘)));. I’m wondering how web designers who don’t know how to program with PHP are able to change stuff/order of the data (alternatives would be CSS or normal (X)HTML templates which are editable with your favourite text editor).

XML_XUL was followed with some live example in the browser. If you remember, XUL is the XML User interface Language for Mozilla based browsers. XML_XUL can generate the XML through PHP. With XUL you are able to build rich client interfaces, as we from ThinkPHP are currently doing for the car rental company Sixt, in a more complex environment.

The last big chapter is dedicated to the WebServices, called XML-RPC and SOAP. Stephan gives a good overview about SOAP, XML-RPC and the newer REST (which is, as one attendee concluded right, nothing new) methods and digs deeper into the PHP5 implementation of SOAP extension (which existed before in PHP4, too) with a SOAP client example connecting to the Google webservice. The SOAP server part is the more complex part although its basic usage is very easy. Björn tells about the problems you will have when using .NET or Java based clients to connect to a PHP based SOAP Server. In your service, it’s not sufficient to return array(‚foo‘,’bar‘), instead you have to deal with SoapVar() and SOAP_ENC_OBJECT (do you want to know more details? Just mail me) to get it work right.

Stephan continues with the brand new XMLRPCi extension by John Coggeshall and shows some examples within the client mode. XMLRPC servers are not supported yet.

Avatar von Björn Schotte

Kommentare

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert


Für das Handling unseres Newsletters nutzen wir den Dienst HubSpot. Mehr Informationen, insbesondere auch zu Deinem Widerrufsrecht, kannst Du jederzeit unserer Datenschutzerklärung entnehmen.