Why don't you just test the length of the matches element?
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute" creationComplete="output()">
<mx:Script>
<![CDATA[
[Bindable]
private var xml1:XML = <root>
<matches/>
</root>;
[Bindable]
private var xml2:XML = <root>
<matches>
<match/>
</matches>
</root>;
private function output ():void
{
r1.text =
XML(xml1.matches).child('match').length().toString();
r2.text =
XML(xml2.matches).child('match').length().toString();
}
]]>
</mx:Script>
<mx:VBox>
<mx:Label text="First Result"/>
<mx:TextInput id="r1"/>
<mx:Label text="Second Result"/>
<mx:TextInput id="r2"/>
</mx:VBox>
</mx:Application>
On 29/11/2006, at 7:56 AM, Daniel Thompson wrote:
I'm trying to see if a response from the server is empty. So, in
one case I
end up with:
<root>
<matches/>
</root>
And in the other, I get:
<root>
<matches>
<match ... />
</matches>
</root>
Using this fancy E4X, how do I test for the different conditions? I
always
seem to be getting back an XMLList, be it empty or not. I can't
imagine I
have to iterate this and check that it's zero at the end, but
length doesn't
do it, and I can't check for null because I'm always getting an
XMLList.
Thanks,
-DT