Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:18219 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 45555 invoked by uid 1010); 19 Aug 2005 06:43:04 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 45539 invoked from network); 19 Aug 2005 06:43:04 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 19 Aug 2005 06:43:04 -0000 X-Host-Fingerprint: 64.233.170.207 rproxy.gmail.com Linux 2.4/2.6 Received: from ([64.233.170.207:18577] helo=rproxy.gmail.com) by pb1.pair.com (ecelerity 2.0 beta r(6323M)) with SMTP id 84/6C-33075-77F75034 for ; Fri, 19 Aug 2005 02:43:03 -0400 Received: by rproxy.gmail.com with SMTP id g11so492217rne for ; Thu, 18 Aug 2005 23:42:59 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=KI75Qtn81JXypL7yv3xEgzIeXhvzekFnwvvWfU1ty/H+BfOM1NcOm92egCBn7s+/+XDOvSMWzZ8H7vBPoo9G0tlcKYcHXuobdkZbj3Ig0k6S1ej4EZPYvmRiXM+eZTSELZ9nGcvezx2uS5xUvEDg7a52RCpGIsPUY9m4cTWg41w= Received: by 10.38.59.29 with SMTP id h29mr15349rna; Thu, 18 Aug 2005 23:42:59 -0700 (PDT) Received: by 10.38.10.25 with HTTP; Thu, 18 Aug 2005 23:42:59 -0700 (PDT) Message-ID: <24e5f3b705081823422adb289c@mail.gmail.com> Date: Thu, 18 Aug 2005 23:42:59 -0700 Reply-To: sterling@apache.org To: Rasmus Lerdorf Cc: internals@lists.php.net In-Reply-To: <43054765.3000208@lerdorf.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: <43054765.3000208@lerdorf.com> Subject: Re: [PHP-DEV] Simplexml and xml namespaces From: sterling.hughes@gmail.com (Sterling Hughes) Hm - that shouldn't be. =20 I think the right solution is that media:title should not show up in the children of node, unless you are looking at the proper namespace, ie, you need to use children() to get the children in that namespace. -Sterling On 8/18/05, Rasmus Lerdorf wrote: > I don't really understand how the current xml namespace handling in > simplexml is useful. >=20 > test.xml: >=20 > > > Title1 > Title2 > Media Title > > >=20 > $xml =3D simplexml_load_file('test.xml'); > $xml->node ends up containing a title array that looks like this: >=20 > ["title"]=3D> > array(3) { > [0] =3D> string(6) "Title1" > [1] =3D> string(6) "Title2" > [2] =3D> string(11) "Media Title" > } >=20 > Of course, I can loop through > $node->children('http://search.yahoo.com/mrss') > and get > ["title "]=3D> > object(SimpleXMLElement)#8 (1) { > [0] =3D> string(11) "Media Title" > } >=20 > But how does this really help? I don't see how it is possible to > distinguish the namespaced title vs. the non-namespaced ones. My > suggestion here would be that for namespaced nodes the namespace alias > (or perhaps the actual namespace?) becomes the key in the nodes array. > As in: >=20 > ["title"]=3D> > array(3) { > [0] =3D> string(6) "Title1" > [1] =3D> string(6) "Title2" > ['media'] =3D> string(11) "Media Title" > } >=20 > So people have a shot at distinguishing from >=20 > Or, alternatively, have a separate arrays: >=20 > ["title"]=3D> > array(2) { > [0] =3D> string(6) "Title1" > [1] =3D> string(6) "Title2" > } > ["media:title"]=3D>string(11) "Media Title" >=20 > The latter is actually what I was (naiively) expecting. >=20 > -Rasmus >=20 > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php >=20 >