NYCPHP Meetup

NYPHP.org

[nycphp-talk] Simple XML discussion at Zend

Adam Maccabee Trachtenberg adam at trachtenberg.com
Tue Jan 20 10:37:11 EST 2004


On Tue, 20 Jan 2004, Tim Gales wrote:

> There is a discussion about SimpleXML in
> PHP Weekly Summary | 19.JAN.2004 at:
> http://www.zend.com/zend/week/week169.php

Unfortunately, I won't swear that my "excellent summary" is what's
actually happening to SimpleXML. There's been a lot of changes since
my message and also some things that I didn't say.

<shameless:plug>

I think right here is a good place to mention that I'll be giving a
short talk at LinuxWorld on Wednesday at 2 pm on "A Sneak Preview of
XML in PHP 5" at the O'Reilly Booth.

More of a general overview than detailed list, but David and myself
can answer questions during the "PHP Cookbook" book signing that will
follow the talk.

</shameless:plug>

But back to SimpleXML. :)

Right now, I would say the changes boil down to:

1) The xquery() method is now named xpath().

2) You can no longer directly validate SimpleXML objects with XML
   Schema.

3) You used to be able to register namespaces to use as
   pseudo-properties and as XPath prefixes with the register_ns()
   method. This has been removed. You now use children() and
   attributes() methods and pass the namespace name. For XPath, you
   pass an additional array of prefix->namespace pairs.

4) The to_xml() and to_xml_file() methods as now one method named
   asXML(). Passing 0 parameters returns the data, passing 1 writes it
   to a file. asXML() now correctly only returns the data from the
   current node downward instead of the whole file.

5) SimpleXML now returns iterators instead of arrays, so you should
   now be able to cycle through results using foreach regardless of
   the number of elements returned. (i.e. even one element works.)

6) SimpleXML behaves in a far more consistent manner, should be less
   buggy, etc, etc.

-adam

-- 
adam at trachtenberg.com
author of o'reilly's php cookbook
avoid the holiday rush, buy your copy today!



More information about the talk mailing list