Hi everybody
I'm studying E4X and I discover how it is powerfull. I agree with Ben:
it is really objects.
just one more detail:
_/[EMAIL PROTECTED]toto means the element subject where the attribute
id equals toto
/subject id=toto .../subject
/while
subject.(@id==toto) means the element subject whith the included
element id equals toto
/subject... idtoto/id .../subject
regards
Hervé
_
Ben Stucki a écrit :
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
--
We're Hiring! Seeking a passionate developer to join our team building
Flex based products. Position is in the Washington D.C.
metro area. If interested contact [EMAIL PROTECTED]
mailto:[EMAIL PROTECTED]
*From*: Pedro Pastor [EMAIL PROTECTED]
*Sent*: Friday, February 09, 2007 6:26 PM
*To*: flexcoders@yahoogroups.com
*Subject*: [flexcoders] New to the group
Hello to all of you.
I have just entered this group. I am quite new to those technologies
(Flex 2 and ActionScript 3).
After reading some documentation I'm doing some practising and I have
some questions to this community.
1) E4X query language:
I'm used to work with XPath for dealing with XML structures. I've
tried to do some (not very complicated) queries using E4X BUT it seems
like E4X doesn't work the same way (and it is far from fulfilling the
XML queries needs). For example, given the following XML date:
ROOT
record
data. /data
subject id=c001/name
subject id=c002BB/name
subject id=c003CCC/name
/record
record
data. /data
subject id=c001/name
subject id=c005H/name
/record
And so on...
/ROOT
Using an mx:HTTPService id=idHTTPService .. resultFormat=e4x
And asking for:
idHTTPService.lastResult.record .( [EMAIL PROTECTED]c001
mailto:[EMAIL PROTECTED])
this query only provides the record elements that have ONLY ONE
subject child AND has an @id == c001. I mean, the record tags
with more than one subject children always fail.
-Is this the correct behaviour?
-How can I perform such type of query?
Thank you very much in advance.
Pedro
--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.441 / Virus Database: 268.17.32/677 - Release Date:
08/02/2007 21:04