Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:11833 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 8185 invoked by uid 1010); 2 Aug 2004 20:58:59 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 8150 invoked from network); 2 Aug 2004 20:58:59 -0000 Received: from unknown (HELO mproxy.gmail.com) (64.233.170.201) by pb1.pair.com with SMTP; 2 Aug 2004 20:58:59 -0000 Received: by mproxy.gmail.com with SMTP id 78so226643rnl for ; Mon, 02 Aug 2004 13:58:59 -0700 (PDT) Received: by 10.38.78.25 with SMTP id a25mr85975rnb; Mon, 02 Aug 2004 13:58:59 -0700 (PDT) Message-ID: <24e5f3b704080213583849fc6a@mail.gmail.com> Date: Mon, 2 Aug 2004 13:58:59 -0700 Reply-To: sterling@apache.org To: David Sklar Cc: internals@lists.php.net In-Reply-To: <410EA9DD.6060003@sklar.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit References: <410EA9DD.6060003@sklar.com> Subject: Re: [PHP-DEV] SimpleXML returning attributes as objects instead of strings From: sterling.hughes@gmail.com (Sterling Hughes) iterators... On Mon, 02 Aug 2004 16:53:49 -0400, David Sklar wrote: > 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 > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > >