Here you go:

var employees:XML =
<employees>
        <employee name="joe mark">
                <department id="id1"/>
                <address city="miami" state="florida"/>
        </employee>
        <employee name="joe mark">
                <address city="san francisco" state="california"/>
        </employee>
        <employee name="mary dooley">
                <department id="id1"/>
                <address city="los angeles" state="california"/>
        </employee>
</employees>;
trace (employees.employee.(child ("department")[EMAIL PROTECTED] == "id1"));

--- In flexcoders@yahoogroups.com, "coder_flex" <[EMAIL PROTECTED]> 
wrote:
>
> I have an xml document of the form
> <employees>
>   <employee name="joe mark">
>     <department id="id1"/>
>     <address city="miami" state="florida"/>
>   </employee>
>   <employee name="joe mark">
>     <address city="san francisco" state="california"/>
>   </employee>
>   <employee name="mary dooley">
>     <department id="id1"/>
>     <address city="los angeles" state="california"/>
>   </employee>
> 
> </employees>
> 
> Note here that the second employee record doesnt have department
> element at all. This is just a sample and my original xml is a web
> service response with some of the child elements missing for some
> elements. I want to filter the parent element on the child elements
> which may or may not be present using an e4x expression. The e4x
> expression of the form:
> 
> employeesByDept:XMLList = employees.employee.([EMAIL PROTECTED] 
== "id1");
> 
> fails saying department element not found. If the department 
element
> is found for all the employees the above statement goes through. 
> 
> Whats the work-around for this? I thought its fairly common to have
> child elements/attributes missing within elements and e4x should 
just
> ignore those.
> 
> Thanks in advance for the response.
>






------------------------ Yahoo! Groups Sponsor --------------------~--> 
Great things are happening at Yahoo! Groups.  See the new email design.
http://us.click.yahoo.com/TISQkA/hOaOAA/yQLSAA/nhFolB/TM
--------------------------------------------------------------------~-> 

--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/flexcoders/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to