Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:29697 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 84016 invoked by uid 1010); 23 May 2007 17:07:05 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 84001 invoked from network); 23 May 2007 17:07:05 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 23 May 2007 17:07:05 -0000 Authentication-Results: pb1.pair.com header.from=kenashkov@gmail.com; sender-id=pass; domainkeys=bad Authentication-Results: pb1.pair.com smtp.mail=kenashkov@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.132.240 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: kenashkov@gmail.com X-Host-Fingerprint: 209.85.132.240 an-out-0708.google.com Received: from [209.85.132.240] ([209.85.132.240:15258] helo=an-out-0708.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 0F/76-45184-6B474564 for ; Wed, 23 May 2007 13:07:04 -0400 Received: by an-out-0708.google.com with SMTP id c18so71309anc for ; Wed, 23 May 2007 10:06:55 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references; b=XQHqWbqoq4R9GxKq8xA9Kh4bcRMShlFSYoOS+4v+vIaK+m5Ei4QXkR/B5W2SJB+/OyqjtbqM3J3cyPgdGTrQrNjXJVM/EO/YC5niNaEpEsxhcAvv42tC00BKXXcD13A/R3/lvdIbkkV/Ggs54Ai2ztN521fLI5sut6SABpamo/A= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references; b=Qib2+fU/aKXYq3lu3EsHhdpazBy4f9GHNlrj3GBIedCm6wovixz/AuEDIUmApLBfNGlOjE3Uxh2atU1qY7DCHUh9uRY959fanhTuihST5xkrES9y0SOblqqGUVQ1ZvES6nt0FReBQkPcGSH1oDabXERuzF5kdgD1QktPUhZ05I8= Received: by 10.100.209.10 with SMTP id h10mr690877ang.1179940015280; Wed, 23 May 2007 10:06:55 -0700 (PDT) Received: by 10.100.166.5 with HTTP; Wed, 23 May 2007 10:06:55 -0700 (PDT) Message-ID: <261daaa10705231006k61675247m78324be17f9134d@mail.gmail.com> Date: Wed, 23 May 2007 20:06:55 +0300 To: "kepbepos kepbepos" Cc: internals@lists.php.net In-Reply-To: <799aeacc0705220802v6477968fgc5f8a83c7fb61e1d@mail.gmail.com> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_187186_13266082.1179940015085" References: <261daaa10705220123m41b254a6p6b44d21b29ad1d4c@mail.gmail.com> <799aeacc0705220802v6477968fgc5f8a83c7fb61e1d@mail.gmail.com> Subject: Re: [PHP-DEV] unexpected behaviour in SimpleXML (php 5.2.2) From: kenashkov@gmail.com ("Vesselin Kenashkov") ------=_Part_187186_13266082.1179940015085 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline The attribute is not a child XML node. For walking through attributes SimpleXML has $node->attributes() method. And if($node->attributes()) check works as expected. So I think $node->children() must be just for child XML nodes, not for attributes (there is no sense to give back results for attributes since we have attributes() method). Vesselin Kenashkov On 5/22/07, kepbepos kepbepos wrote: > > Hi, > I'm not an expert, but in your example > > -------- > > $str = ''; > > $x = new SimpleXMLElement($str); > > > > if($x->subnode->children()) > > print 'yes'; > > else > > print 'no'; > > --------- > > will print 'no'; > > > ok no children > > If the > > $str=''; > > it will print yes. > > > ok has one child: > > But the same will happen if the subnode has an attribute like: > > $str = ''; > > > I think is correct, in fact (if I'm right) an attribute is a child. > Following DOM the tree is: > > rootnode > | > subnode > | > id > > Here an example explaining that > http://www.w3schools.com/dom/nodetree.gif > > Please someone else to confirm. > > See you > ------=_Part_187186_13266082.1179940015085--