On Tue, 13 Jan 2004, Christian Schneider wrote: > Adam Trachtenberg wrote:
> > However, I don't really see any way around this otherwise. Either it's > > general or not. It can't be both. (Unless there's some magical type > > that's both an array and a scalar.) I'm willing to put up with this > > Elements are already a magical type which is an object and an array. > Making foreach work on a both the scalar and array incantation of child > elements seems very useful to me. And usefulness seems to be the goal of > SimpleXML as far as I understand. If that can be done, then I am all for it. Maybe we can somehow make an individual item Iterable. > > maxOccurs attributes in the schema for an element. If maxOccurs > 1, > > then the elements would be placed in an array even if there was only one > > element in that particular instance. > > I don't like the idea: Different behaviour with or without schema. I > write code without schema first. If I decide to add a schema later code > has to be rewritten. Not good. Don't do that. Use the schema. :) > > AFAIK, it's actually also impossible to find out the name of the > > document element using SimpleXML, even using XPath. > > Yup, right now the only way is probably to wrap it in a dummy tag before > giving it to SimpleXML. Sounds like a good idea anyway to me, if I have > a domain specific document with varying content I'd probably do > <domain>...</domain> anyway. Unless, of course, you're not in control over those documents. > >> I would actually expect abcd but only once: > >> Node Value: abcd > >> > >> Concatenating all text parts _and_ returning them once for each part > >> definitely seems wrong. > > > > Aren't those two lines contradictory? :) > > Why? Right now it returns abcd twice which is definitely wrong. > Returning ab and cd or (preferably IMHO) abcd once seems right. Sorry. I misread. I thought you wrote "returning them once definitely seems wrong." I agree that we should return "abcd" in this case. -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