Here is another possibility.

 

Climb up the ancestor chain, saving the current node's childIndex() at
each point, maybe in a delimited string.  You chould then "replay" that
string, using .child(i) to retrace your path.

Tracy

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of Tracy Spratt
Sent: Friday, February 01, 2008 3:21 PM
To: [email protected]
Subject: RE: [flexcoders] Re: How can I save XML path deep inside my XML
data ?

 

Yes, you will need to do something like this, save a reference.  On
problem is that you can't easily run-time parse a string representation
of an e4x expression.  Look in the archives, there are some techniques
that let you do it, but they are not simple.

 

Save a reference, that is probably the best way.

 

Another possibility: Find your node, then assign a special id attribute,
with a unique string id value.  Then use e4x to locate the node using
that string id.

 

Tracy

 

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of Jhonny Everson
Sent: Thursday, January 31, 2008 9:48 PM
To: [email protected]
Subject: Re: [flexcoders] Re: How can I save XML path deep inside my XML
data ?

 

I guess you haven't explained very well yet. But let's present you some
approach that MAY be what you are looking. That's saving the reference.

var lastMatch:XML;

for (...){
   if( condition_matched){
        lastMatch = (absolute path); //
myXml.books[0].book.covers.cover[2].items[2].data123 for example
        break;
   }
}

then you can use lastMatch as a reference to that absolute path.




On Jan 31, 2008 10:18 PM, helihobby <[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]> > wrote:

I mean, I would like to be able to get the same exact location in the
XML path every time I run my for loop and stop on some condition.

For example some sort of function that returns:



myXml.books[0].book.covers.cover[2].items[2].data123

if data123 is the value in my For Loop that I break on ( match on ) on
the XML in question.

Hope this helps,

Sean.



--- In [email protected] <mailto:flexcoders%40yahoogroups.com>
, "Tracy Spratt" <[EMAIL PROTECTED]> wrote:
>
> What do you mean by "...save the absolute path..."? 
> 
> 
> 
> Save a reference?
> 
> 
> 
> Save a string representation of the ancestor chain?
> 
> 
> 
> What do you want to do?
> 
> 
> 
> Tracy
> 
> 
> 
> ________________________________
> 
> From: [email protected] <mailto:flexcoders%40yahoogroups.com>
[mailto:[email protected] <mailto:flexcoders%40yahoogroups.com>
] On
> Behalf Of helihobby
> Sent: Thursday, January 31, 2008 6:42 PM
> To: [email protected] <mailto:flexcoders%40yahoogroups.com> 
> Subject: [flexcoders] How can I save XML path deep inside my XML data
?
> 
> 
> 
> Hello,
> 
> I have a very large XML.
> 
> I have a function which reads the XML and finds something that I am
> looking for ( lets say data123 )
> 
> Once I find it I wish to save the absolute path to it ...
> Is that possible ?
> 
> For example:
> 
> I wish to save:
> 
> myXml.books[0].book.covers.cover[2].items[2].data123
> 
> However I can not build the above statement since the XML is dynamic.
> I wish for the function to return the absolute path of the item after
> I find it ...
> 
> Thanks in advance,
> 
> Sean.
>




-- 
Jhonny Everson 

 

Reply via email to