Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:19881 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 78833 invoked by uid 1010); 1 Nov 2005 11:28:28 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 78817 invoked from network); 1 Nov 2005 11:28:28 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 1 Nov 2005 11:28:28 -0000 X-Host-Fingerprint: 216.117.147.250 unknown Linux 2.4/2.6 Received: from ([216.117.147.250:48102] helo=ctindustries.net) by pb1.pair.com (ecelerity 2.0 beta r(6323M)) with SMTP id 86/71-02082-B5157634 for ; Tue, 01 Nov 2005 06:28:28 -0500 Received: from [127.0.0.1] (dsta-aa203.pivot.net [66.186.171.203]) (authenticated bits=0) by ctindustries.net (8.12.8/8.12.8) with ESMTP id jA1AHWtI018130; Tue, 1 Nov 2005 05:17:34 -0500 Message-ID: <436752F2.9020908@ctindustries.net> Date: Tue, 01 Nov 2005 06:35:14 -0500 User-Agent: Mozilla Thunderbird 1.0.7 (Windows/20050923) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Marian Kostadinov CC: internals@lists.php.net References: <4365E1AA.4020602@bitflux.ch> <200511010921.04064.bu@orbitel.bg> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: ClamAV 0.87/1151/Mon Oct 31 13:34:04 2005 on ctindustries.net X-Virus-Status: Clean Subject: Re: [PHP-DEV] Is really no one interested? From: rrichards@ctindustries.net (Rob Richards) Marian Kostadinov wrote: >//But how can I understand what is the name of the root node? >$dom_sxe = dom_import_simplexml($sxe1); > >//Hooray, we've got node name >echo $dom_sxe->nodeName; > >//And what happens if element sequence changes? . >echo $dom_sxe->childNodes->item(1)->firstChild->firstChild->firstChild->nodeValue; >//... hm... I prefer SimpleXML. > > The API is to be kept simple and what you are asking for can be done extending the SimpleXMLElement and the functions are a whole 1 line of user code: nodeName; } function getType() { return dom_import_simplexml($this)->nodeType; } } $xml = ''; $sxe = simplexml_load_string($xml, 'cNode'); print $sxe->getName()."\n"; print $sxe->getType()."\n"; ?> Of course XPath could be used in place of DOM too though. Rob