On Tue, 23 Mar 2004, Rasmus Lerdorf wrote: > they are all in sync. For example, Derek Ford's simplexml-related message > to internals last week(*) worries me somewhat. He passed on what looks to > be some basic brokeness in the extension which nobody has addressed so > far. > > (*) http://news.php.net/article.php?group=php.internals&article=8660
Here's my take on these issues: 1: You can't tell if an element exists or not This one appears to be a real issue, as someone else asked me this exact question earlier today. I can suggest a couple of work arounds, like casting the object to a string and checking if it's empty (gross) or counting the number of elements returned by an XPath query (not Simple). However, this is really the symptom of a more fundamental issue: SimpleXML is not an introspective API. It works great when you know what you're looking for, but breaks down when you're trying to figure out what's there. (For instance, you can't figure out what's the tag name of the root element.) I believe this is somewhat of a conscious decision, but one that may disappoint users. 2: XPath doesn't work with default namespaces I either have or (used to have) a patch to fix this. Due to how XPath handles default namespaces, you need to explicitly associate a prefix with the default URI. Right now, we don't let you do this and it needs to be fixed. This is something that got eliminated during the redesign a few months back and I forgot to add it back. 3: Elements with namespaces aren't referencable. Namespaces are just a bitch in general. I need to double check how this shook out, but I think we ended up forcing people to use the actual namespace URI instead of the prefix because of some nasty issues and edge cases. Rob will know better than I, as he actually coded the thing and all I did was kibbitz. -adam -- [EMAIL PROTECTED] author of o'reilly's php cookbook avoid the holiday rush, buy your copy today! -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php