I'm glad I got to this before anyone spent their precious time on it.
Unfortunately, the problem was not with my code but stemmed from my
fundamental understanding (or misunderstanding) of an XMLListCollection.
Turns out XMLListCollections aren't magical gateways into hierarchal
data. As far as I can tell, they are essentially flat structures that
hold a reference to a list. I'll explain my failed attempt and hope
that it will help somebody avoid the same mistake. Here's roughly what
my data looks like:
<node nodeId="1"><node nodeId="2"><node nodeId="3"/><node
nodeId="4"/><node nodeId="5"><node nodeId="6"><node nodeId="7"/><node
nodeId="8"/><node nodeId="9"/></node><node
nodeId="10"/></node></node></node>
I was trying to apply the following filter function on the
XMLListCollection to view a single child branch:
public function viewBranch(xmlItem:XML):Boolean {return
xmlItem.descendants()....@nodeid == selectedNodeId; // where selectedNodeId
corresponds to the appropriate nodeId }
The problem with this is there is only one object in the
XMLListCollection and it is either filtered out or it is not. Since
the single list contains all values for nodeid, any proper value for
selectedNodeId will result in the entire list being included in the
view. Ah well, live and learn.
I've since moved away from XMLLists, but if anyone has an idea of how to
perform the original task with XMLListCollections I'd love to hear it.
Cheers,
Aaron
--- In [email protected], "aaronmfoster" <aaronmfos...@...>
wrote:
>
> Howdy everyone,
>
> I'm struggling with an XMLListCollection filter function. My xml is
similarly structured to this:
>
> <node>
> <node>
> <node/>
> <node/>
> </node>
> <node>
> <node/>
> <node/>
> </node>
> <node>
>
> It consists of a root node, with zero or more child nodes. The child
nodes could also have zero or more child nodes. Basically it's your run
of the mill xml. =P
>
> I'm looking for a filter function which allows me to view a single
child branch. In other words filter out all but a particular child node
and it's children. Effectively it would turn the view into this:
>
> <node>
> <node/>
> <node/>
> </node>
>
> The goal is to keep the original xml unaltered, while creating a view
of a child node that appears to be the root. The view will then be
applied to several components. Although I've struggled with with it, a
filter seems like the simplest way to go. I'd greatly appreciate any
suggestions.
>
> Thanks,
> Aaron
>