Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:11832 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 85681 invoked by uid 1010); 2 Aug 2004 20:53:49 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 85657 invoked from network); 2 Aug 2004 20:53:49 -0000 Received: from unknown (HELO home.sklar.com) (24.199.89.111) by pb1.pair.com with SMTP; 2 Aug 2004 20:53:49 -0000 Received: from [127.0.0.1] ([127.0.0.1]) by home.sklar.com with Microsoft SMTPSVC(6.0.2600.1106); Mon, 2 Aug 2004 16:53:49 -0400 Message-ID: <410EA9DD.6060003@sklar.com> Date: Mon, 02 Aug 2004 16:53:49 -0400 User-Agent: Mozilla Thunderbird 0.7.1 (Windows/20040626) X-Accept-Language: en-us, en MIME-Version: 1.0 To: internals@lists.php.net Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 02 Aug 2004 20:53:49.0962 (UTC) FILETIME=[CFE5B6A0:01C478D2] Subject: SimpleXML returning attributes as objects instead of strings From: sklar@sklar.com (David Sklar) SimpleXML returns attribute values as SimpleXMLElement objects instead of strings. E.g, given this: $sxe = simplexml_load_string('Doc Ock'); $sxe['arms'] and $sxe['legs'] are SimpleXMLElement objects. This mostly works OK, but causes problems when using empty() to test if an attribute has a value. empty($sxe['arms']) is false, but so is empty($sxe['legs']). An easy workaround is to use strlen() instead of empty(), I suppose (except if an attribute value is "0"), but I am wondering why SimpleXML works this way. Thanks, David