Re: Any XML people around here?

From: Date: Wed, 27 Sep 2000 07:14:55 +0000
Subject: Re: Any XML people around here?
References: 1  Groups: php.windows 
Request: Send a blank email to php-windows+get-2824@lists.php.net to get a copy of this message
Hi, Ernst You have two built-in options with XML and PHP at present. Both of which appear to implement non-validating XML parsers. The first option is to use the Expat parser which has been integrated into PHP for some time. This is an event based parser which does not create a representation of the Document Object Model (DOM) for your XML document in memory. It requires you to provide event handlers in PHP which are called as Expat parses the XML text. With Expat, what you do in the event handlers is entirely up to you. Thus, there is only support for the initial acquiring (reading) of the XML with Expat. There does not appear to be any support for writing the XML back out again. <http://www.phpwizard.net/resources/tutorials/xml_with_php.html> The second option, only available with later versions of PHP4 (like 4.0.2), is the DOMXML-based calls. This stuff is built as a wrapper around the LibXML code; LibXML was developed as part of the GNOME project. The PHP DOMXML stuff is included in the source distribution (4.0.2) and is generally built into the binaries you'll find around the net. For one example, the Win32 build from www.php4win.de includes it. Now, the LibXML code actually creates an internal representation of the XML DOM within memory (LibXML's memory) as the XML is parsed. Using the PHP wrapper interfaces allows you to use properties and methods on the "elements" of the XML in your PHP code to get and set attributes and to get the value of the content of the "elements". It must be stressed that this PHP wrapper around LibXML doesn't expose the full functionality of LibXML. In particular, for example, though you can create new elements (nodes) in your DOM representation you appear to have no way to delete or "prune" elements (or attributes for that matter) from the DOM once created/added. Further, there appears to be no way to change the value of the content of an element in the LibXML DOM once it is created. While all of this functionality is available through LibXML itself, it is yet to be exposed by the wrapper for PHP coders to use. This can be a severe limitation for your PHP XML implementation, depending upon what you're trying to do. That there appears to be a representation of the DOM in LibXML and another (often partial) one in PHP (using the Zend structures) can make for some tricky interactions regarding what is updated when. Another good point, though; the PHP wrapper does provide direct support for writing out the DOM structure back to an XML file. This is a major plus over the Expat approach, IMO. I have been investigating the use of XML and PHP for a major project currently in development. I am using the DOMXML version, and am working with, and around, the limitations (I need to read, modify, and output the XML representation). Liberal use of xmltree() and print_r() has helped my understanding of the code enormously. Another aid has been to simply read the source code in php_domxml.c I don't have any specific web references for the DOM XML stuff. There is a book by Tobias Ratschiller and Till Gerken, named "Web Application Development with PHP 4.0" (ISBN:0-7357-0997-1, published by New Riders) which gives some information on the DOM XML integration with PHP. One note of caution, as it says in the book itself; this material in the book was written at an early stage in the development of the LibXML integration with PHP and I know that some of the code examples are wrong, but I still think it is useful to get you going. I hope this is of some use. Cheers, S t u a r t . php-windows-digest-help@lists.php.net wrote: > [snip] > > Subject: Any XML people around here? > Date: Thu, 21 Sep 2000 09:50:21 +0200 > From: jaffa@pdsg.co.za (Ernst Bekker) > To: <php-windows@lists.php.net> > > I think I have almost folded under the pressure :) > > The w3c documents on XML says allot but I hope that it works good with PHP, > there's allot about java and XML, and obviously sun had something to do with > that. > If anyone here use PHP with XML or vise versa please give me some tips or > direct me to XML/PHP resources on the net please. > > Regards > > E r n s t B e k k er > <Apropriate Job Title> Dev dewd </Apropriate Job Title> > <Company> WEB est. of the PDS Group </Company> > <Phone> (011) 975 4492 </phone> > <e mail> jaffa@pdsg.co.za </email>

« previous php.windows (#2824) next »