On 15/11/2007, Rich Shupe <[EMAIL PROTECTED]> wrote:
> Don't use XPath. You'll lose speed and will have to convert the code to AS3.

Well, there is an AS3 XPath library:
http://code.google.com/p/xpath-as3/

However, it turns out that the .. operator actually was returning a
recursive search, it was other stuff that was preventing all the nodes
from being displayed properly.

> parentNode is not E4X. You're mixing legacy support with E4X you want the
> parent() method. Here's an excerpt from an example in a book that comes out
> in a few weeks.

Aha, that's cool - thanks for pointing that out.

> First, node..node returns an XMLList. So, the first line in the
> readXMLData() function returns an XMLList object, or an array of all the
> nodes that satisfy your query.

Yeah, about that... a related XMLList question - when I do an e4x
query, and get back an XMLList, does the e4x parser create clones of
the nodes that match, or does it just give me an array of references
to the relevant nodes? Because that's quite important - ideally I'd
like to only have one set of XML data, and obviously if every E4x
query creates a new dataset fragment I need to handle that
accordingly. For example, if I select nodes via e4x and then modify
the result, will that change the original XML object?


> The second line shows the first item in that list, and the third line shows
> the parent of that item.
>
>
>
> var book:XML;
>
> function createBasicStructure() {
>     book =    <book>
>                   <publisher name="O'Reilly" />
>                   <title>Learning ActionScript 3.0</title>
>                   <subject>ActionScript</subject>
>                 <authors>
>                     <author>
>                         <firstname>Rich</firstname>
>                         <lastname>Shupe</lastname>
>                     </author>
>                     <author>
>                         <firstname>Zevan</firstname>
>                         <lastname>Rosser</lastname>
>                     </author>
>                 </authors>
>             </book>;
> }
>
> function readXMLData() {
>     trace(book..author);
>     trace(book..author[0]);
>     trace(book..author[0].parent());
> }
>
> createBasicStructure();
> readXMLData();


So, what if you have a tree structure - how would you most efficiently
process that, for an unknown number of levels? I'm starting to think
recursion might be the only robust way, which kind of sucks.

Or maybe there's a simple algorithm for this type of structure that
I'm just unaware of?

Cheers,
Alias

> On 11/15/07 11:51 AM, "Alias " <[EMAIL PROTECTED]> wrote:
>
> > Aha, xml.parentNode should do the trick.
>
>
>
> _______________________________________________
> osflash mailing list
> [email protected]
> http://osflash.org/mailman/listinfo/osflash_osflash.org
>

_______________________________________________
osflash mailing list
[email protected]
http://osflash.org/mailman/listinfo/osflash_osflash.org

Reply via email to