Hi Ben,

Thank you very much for your response. Here you are my comments: 

1) The "=" / "==" error is just a typing error in my e-mail. This
symbol was properly set in my code.

2) I've tried your suggestion but it doesn't work. That query provides
ALL the <record> elements in the XML tree. Using the very same code
but removing the internal "()" for the (@id == "c001") filter, it
provides me with the matching <record> elements BUT only those having
ONLY ONE <subject> children (and having @id = "c001").

3) The point is I need to check (filter) at children level (<subject>)
in order to get the appropriate parent node-set (<record>). That's
very easy in XPath, but I'm getting quite confusing with E4X. 


I've been developing XML application form years, and I've been dealing
with XML+XSLT+ … some other dynamic HTML technologies and I find
Flex+ActionScript is a big step forward in the client web application
realm, but the way ActionScript deals with XML is a bit deceiving.


Best regards,

Pedro

--- In [email protected], "Ben Stucki" <[EMAIL PROTECTED]> wrote:
>
> 
>               Hey Pedro,
> 
> Welcome to FlexCoders!
> 
> I came into E4X with a background in XPath as well and think the
> biggest hurdle in learning E4X was understanding the methodology behind
> it.  XPath is intended as a query language for XML. In contrast I think
> of E4X more like an object representation of XML. This means it can
> treat results a little differently based on the form of the XML , such
> as when you get results with only one subject node but not with
> multiple subject nodes. I've found that while I work with XPath from
> the top down, I get the best results from E4X when I check it from the
> inside out. Here's how the original query works out.
> 
>                                               idHTTPService.lastResult.record
> 
>                                               .(
> 
>                                               [EMAIL PROTECTED]"c001")
> 
> The inner most part is @id="c001". The main problem with this is that
> it uses the assignment (=) operator and not evaluation (==). This means
> that istead of looking for an id attribute value of "c001", it's
> actually creating or overrideing the id attribute. So we'll change that
> to ==.
> 
>                                               idHTTPService.lastResult.record
> 
>                                               .(
> 
>                                               [EMAIL PROTECTED]"c001")
> 
> The next part to evaluate is [EMAIL PROTECTED]"c001". The problem here is
> that while @id=="c001" is meant as a filter, it's not in parenthesis.
> So we'll change that to subject.(@id=="c001") .
> 
> The rest works already, so here's the end result.
> 
>                                               idHTTPService.lastResult.record
> 
>                                               .(
> 
>                                               subject.(@id=="c001"))
> 
>                               It takes a little getting used to, but I've 
> found that E4X can
normally handle what I need it to do.
> 
> Ben Stucki


Reply via email to