> I can accept getChildren() and getAttributes() (or better, just > children() and attributes()) as methods on objects, but I'm not happy > with them at all. These two methods were considered for inclusion in > my original thoughts on simplexml, and I decided against them for the > reasons I've mentioned above. Anyhow, shall we put it to a vote on > these two methods and move on? > > I'm -1 on having them.
Yes I now remember when that array accessors for the attributes was added my bad. +1 on the getChildren() and attributes() (or whatever name they may be) assuming they both work and return arryas even when empty. These are 2 functions which are pretty standard in a lot of xml coding . The other functions are not a big deal as they can be implemented off the returns of those (hasChildren - just test the return from getChildren. count - count the array items). Remember xpath may not have been compiled into libxml so there is no guarantee that it will be available, though highly unlikely it wouldnt be. As far as the xpath issue and return type, I mean the returned node type. Following will segfault as its returning namespace nodes and not and element or attribute node: $foo = simplexml_load_string('<foo xmlns:a="http://bar"><foo2/></foo>'); $ns = $foo->xsearch('//namespace::*'); var_dump($ns); the following crash as well (at least under windows) due to the iter stuff: $children = $foo->hasChildren(); foreach($foo->getChildren() as $child) { var_dump($child); } print $foo->key(); -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php