Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:18217 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 36921 invoked by uid 1010); 19 Aug 2005 02:43:56 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 36906 invoked from network); 19 Aug 2005 02:43:56 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 19 Aug 2005 02:43:56 -0000 X-Host-Fingerprint: 204.11.219.139 lerdorf.com Linux 2.4/2.6 Received: from ([204.11.219.139:49123] helo=colo.lerdorf.com) by pb1.pair.com (ecelerity 2.0 beta r(6323M)) with SMTP id 37/81-33075-B6745034 for ; Thu, 18 Aug 2005 22:43:55 -0400 Received: from [192.168.200.106] (c-24-6-1-160.hsd1.ca.comcast.net [24.6.1.160]) (authenticated bits=0) by colo.lerdorf.com (8.13.4/8.13.4/Debian-3) with ESMTP id j7J2ho5k018164 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT) for ; Thu, 18 Aug 2005 19:43:51 -0700 Message-ID: <43054765.3000208@lerdorf.com> Date: Thu, 18 Aug 2005 19:43:49 -0700 User-Agent: Mozilla Thunderbird 1.0.6 (Macintosh/20050716) X-Accept-Language: en-us, en MIME-Version: 1.0 To: internals@lists.php.net X-Enigmail-Version: 0.92.0.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Simplexml and xml namespaces From: rasmus@lerdorf.com (Rasmus Lerdorf) I don't really understand how the current xml namespace handling in simplexml is useful. test.xml: Title1 Title2 Media Title $xml = simplexml_load_file('test.xml'); $xml->node ends up containing a title array that looks like this: ["title"]=> array(3) { [0] => string(6) "Title1" [1] => string(6) "Title2" [2] => string(11) "Media Title" } Of course, I can loop through $node->children('http://search.yahoo.com/mrss') and get ["title "]=> object(SimpleXMLElement)#8 (1) { [0] => string(11) "Media Title" } 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: ["title"]=> array(3) { [0] => string(6) "Title1" [1] => string(6) "Title2" ['media'] => string(11) "Media Title" } So people have a shot at distinguishing from Or, alternatively, have a separate arrays: ["title"]=> array(2) { [0] => string(6) "Title1" [1] => string(6) "Title2" } ["media:title"]=>string(11) "Media Title" The latter is actually what I was (naiively) expecting. -Rasmus