Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:7543 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 39091 invoked by uid 1010); 4 Feb 2004 14:45:06 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 38941 invoked from network); 4 Feb 2004 14:45:06 -0000 Received: from unknown (HELO phoebe.host4u.net) (209.150.128.26) by pb1.pair.com with SMTP; 4 Feb 2004 14:45:06 -0000 Received: from ctdprimary (dsta-aa203.pivot.net [66.186.171.203]) by phoebe.host4u.net (8.11.6/8.11.6) with SMTP id i14EiYO16210; Wed, 4 Feb 2004 08:44:34 -0600 Message-ID: <015101c3eb2d$ae142f80$f7dea8c0@cyberware.local> To: "Adam Maccabee Trachtenberg" , "Derick Rethans" Cc: "PHP Developers Mailing List" References: Date: Wed, 4 Feb 2004 09:46:31 -0500 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 Subject: Re: [PHP-DEV] SimpleXML->children() and text nodes From: rrichards@ctindustries.net ("Rob Richards") Adam's pretty much correct with his statements on this. The children() method's real purpose is for using namespaces within the document. Without an argument, it retrieves child elements within the default namespace, otherwise it will retrieve elements within the namespace passed in. It also sets the namespace scope for the sxe object. nsuri is considered to be the namespace uri in the following example:. $children = $sxe->children("nsuri"); $myelement = $children[0]->myelement; The call to $children[0]->mylement will retrieve the myelement child nodes within the nsuri namespace (since $children is set to the nsuri scope). The same pretty much hodls true for attributes() as well. Rob From: Adam Maccabee Trachtenberg > On Sun, 1 Feb 2004, Derick Rethans wrote: > > > when I iterate over $s->body->children() I only get the and > > the . Shouldn't it also show the text nodes? > The SimpleXML model prefers you to not mix element and text nodes > side-by-side. You can, and it won't complain, but (IMHO) the theory is > that an element should either contain other elements or a single text > (or CDATA) node. This is a more "XML-centric" viewpoint towards data > than an "HTML-centric" perspective. (Realize these are generalizations > here about the nature of XML and HTML.)