On Mon, 1 Dec 2003, George Schlossnagle wrote:

> [puts on evil twin hat]

Theo?

> To play devil's advocate to the idea - the problem with it is that it
> requires a bunch of extra code when examining an unknown document.
> This is similar to the (promised by Sterling to be fixed) quirk of
> SimpleXML returning a string when a chile has a single descendent of a
> given name and an array otherwise.  This seems intuitive at first, but
> means that you need to always check the type of your value before you
> use it.  The same problem exists here.

If you're trying to examine an unknown document using SimpleXML,
you're in deep trouble. I don't think SimpleXML really gives you the
introspection features that one needs for crawling the tree.

For instance, you can't look at attributes at all unless you already
know they exist because we've overloaded foreach to iterate through
an object's children nodes instead of its "array elements." (Using the
correct syntax here with all the overload is difficult.)

SimpleXML is best when you're already somewhat familiar with the
schema. (IMO)

I was trying not to bring up the scalar/array bit because I knew that
would just open up a whole new can of worms. Sterling told me at
ApacheCon that he'd fix this, but I'll believe him when I see the
code. :)

I've run into the single/multiple bit before in my actual programs,
and I've also run into occasions where an element was
missing. However, I've yet to run into occasions when I thought
something would be a parent and it turned out to be a leaf. Have you?

-adam

-- 
[EMAIL PROTECTED]

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to