Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:7053 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 87576 invoked by uid 1010); 13 Jan 2004 16:31:12 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 87531 invoked from network); 13 Jan 2004 16:31:11 -0000 Received: from unknown (HELO xaxa.search.ch) (195.141.85.117) by pb1.pair.com with SMTP; 13 Jan 2004 16:31:11 -0000 Received: from localhost (localhost [127.0.0.1]) by xaxa.search.ch (Postfix) with ESMTP id 5AB206DB1F; Tue, 13 Jan 2004 17:31:11 +0100 (CET) Received: by xaxa.search.ch (Postfix, from userid 65534) id 56B1D6DB24; Tue, 13 Jan 2004 17:31:10 +0100 (CET) Received: from cschneid.com (ultrafilter-i [192.168.85.2]) by xaxa.search.ch (Postfix) with ESMTP id 03D446DB1F; Tue, 13 Jan 2004 17:31:09 +0100 (CET) Message-ID: <40041D4B.9060900@cschneid.com> Date: Tue, 13 Jan 2004 17:31:07 +0100 User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.5) Gecko/20031009 X-Accept-Language: de-ch, en-us, en MIME-Version: 1.0 To: Adam Trachtenberg Cc: Rob Richards , internals@lists.php.net References: <00fe01c3d9d1$6e8618a0$f7dea8c0@cyberware.local> <4003FEFA.2090700@cschneid.com> In-Reply-To: X-Enigmail-Version: 0.76.7.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Checker-Version: SpamAssassin 2.61 (1.212.2.1-2003-12-09-exp) on xaxa.search.ch X-Spam-Level: X-Spam-Status: No, hits=0.1 required=5.0 tests=BAYES_44,HTML_MESSAGE autolearn=ham version=2.61 X-Virus-Scanned: by AMaViS 0.3.12pre8 Subject: Re: [PHP-DEV] SimpleXML: Moving Forward From: cschneid@cschneid.com (Christian Schneider) Adam Trachtenberg wrote: > Ugh. This is pretty much the limit of what I think is reasonable for > SimpleXML to handle. It think the API would be more consistent if the Agreed. I was just curious how it behaves if I push it to the limit :-) > 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. > 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. > Again, my opinion is that arbitrary XML documents are best parsed using > DOM and well-defined ones are best parsed using SimpleXML. I agree but I think I'll have something like ... with 0 - many options quite often and iterating should be a simple foreach IMHO. > 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 ... anyway. >> 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. - Chris