It returns an empty XMLList. //var result : XML = XML (e.result); //var result : XML = <response><fault/></response>; var result : XML = <response><user/></response>; if (result.user.length ()) trace("Yippee!"); if (result.fault.length ()) trace("Boo!");
trace (result.user.length ()); trace (result.fault.length ()); --- In flexcoders@yahoogroups.com, "tddclare" <[EMAIL PROTECTED]> wrote: > > I'm trying a simple test, and either it's monday or my brain is > broken... maybe both... > > I'm writing a login component, and fire off a HTTP service that > returns XML as E4X. The response XML is a <response> tag with either > a <user> tag or a <fault> tag inside of it. > > All I want to do is test if there is a user or fault in the response! > > I'm trying this: > private function handle(e:ResultEvent):void { > if (e.result..user) { > trace("Yippee!) > } > if (e.result..fault) { > trace("Boo!) > } > } > > The event is firing, but I always get "Yippee" even when I point at a > file that has NO user tag. > > I've replaced the conditional with everything I can think of: > e.result..user != null > e.result..user != "" > > but it seems to fire no matter what. > > If the E4X parser does NOT find the descendant, what does it return? > Is this documented anywhere in the (not so good) Flex/AS3 documentation? > > Thanks! > > -- TC >