Because your second query returns an empty list instead of null. So, instead of checking for null, just check the length of the result.
trace(describeType(xml1.lobby)); trace(xml1.lobby.length()); // 1 trace(describeType(xml2.lobby)); trace(xml2.lobby.length()); // 0 The first time I noted this it also confused me. I think it's clearly a feaure, though, and it actually makes sense to me, because, otherwise, you couldn't safely write something like this: trace(xml1.lobby.user); trace(xml2.lobby.user); If at some point your query returned null, you'd have to check for null explicitly or wrap almost every single line of code that manipulates XML in try/catch to make sure it doesn't blow up because of a null reference error. Cheers Juan Pablo Califano 2010/2/6 Alexander Farber <alexander.far...@gmail.com> > Hello, > > I've prepared a simple test case for my problem: > > var xml1:XML = > <pref> > <lobby> > <user id="DE2" name="Alex" avatar="2_1211369175.jpg"/> > </lobby> > <game id="0"/> > </pref>; > > var xml2:XML = > <pref> > <user0 id="DE2" name="Alex" avatar="2_1211369175.jpg"/> > </pref>; > > if (xml1.lobby) > trace('1: in the lobby'); > > if (xml2.lobby) > trace('2: in the lobby'); > > Why does this print the 2nd line too? > > 1: in the lobby > 2: in the lobby > > I keep trying and also look in the debugger and just don't get it... > > Thank you > Alex > _______________________________________________ > Flashcoders mailing list > Flashcoders@chattyfig.figleaf.com > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders > _______________________________________________ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders