Instead of casting I would just retrieve the XML from the list:

var myXML : XML = myXMLList[0];

- Daniel Freiman


On Mon, Jul 14, 2008 at 2:13 AM, Rajan Jain <[EMAIL PROTECTED]> wrote:

>   Hi
>
>
>
> I think it is better to use XMLList.length(). IF you one child it will be
> 1.
>
> Hope this helps.
>
>
>
> Thanks
>
> ilikeflex
>
>
> ----- Original Message ----
> From: Sergey Kovalyov <[EMAIL PROTECTED]>
> To: flexcoders@yahoogroups.com
> Sent: Monday, July 14, 2008 1:50:26 AM
> Subject: [flexcoders] Cast XMLList with 1 child to XML
>
>  Hi All!
>
> Is it correct to cast XMLList with 1 child to XML like this:
>
> var myXMLList : XMLList = sourceXML..item. (@id == 1); // It is guaranteed
> that only one node with name == item and attribute id == 1 exists in
> sourceXML.
> var myXML : XML = XML(myXMLList) ;
>
> Actually it works and it fails only when I change the sourceXML thus there
> are more then one node with name == item and attribute id == 1 in it. In
> this case exception is thrown. But I would like to know is it correct
> approach in general or not.
>
> Sergey.
>
>  
>

Reply via email to