That should be: (@id==sId)
From: flexcoders@yahoogroups.com
[mailto:flexcoders@yahoogroups.com] On Behalf Of Tracy
Spratt
Sent: Wednesday, May 24, 2006
11:13 PM
To: flexcoders@yahoogroups.com
Subject: RE: [flexcoders] Re:
XMLListCollection search [f2b3]
Graham,
Won’t e4x get you further than you
are using it?
Untested code:
var xml:XML = <element
id="hello">
<element id="world">
<element
id="123"/>
<element
id="graham"/>
<element
id="weldon">
<element id="office">
<element id="thing"/>
<element id="boat"/>
<element id="chair"/>
</element>
<element id="person"/>
</element>
</element>
</element>
var sId:String = “boat”;
var xlc:XMLCollectionList = new
XMLCOllectionList(xml.descendants(@id=sId)); //Should return a single ietm in
the collection <element id=”boat”>
Again, untested.
Tracy
From: flexcoders@yahoogroups.com
[mailto:flexcoders@yahoogroups.com] On Behalf Of Graham Weldon
Sent: Wednesday, May 24, 2006
10:08 PM
To: flexcoders@yahoogroups.com
Subject: Re: [flexcoders] Re:
XMLListCollection search [f2b3]
Hi Tim,
A good suggestion. Unfortunately my collection is
not sorted, and a sort would cause some issues with the display of the Tree
that uses my collection as a dataProvider.
Bryan,
Your code example is good, but I feel that it will
only work for 2 levels of nodes.
My XML structure has no limit to the number of
levels of nodes. Thus its an n-level tree.
I have however attempted the following approach
with success! Please feel free to use this code sample:
=============================================================
===== XML Example
=============================================================
<element id="hello">
<element id="world">
<element
id="123"/>
<element
id="graham"/>
<element
id="weldon">
<element id="office">
<element id="thing"/>
<element id="boat"/>
<element id="chair"/>
</element>
<element id="person"/>
</element>
</element>
</element>
=============================================================
=============================================================
===== FUNCTION: insertItem(_parentId, _child)
=============================================================
public function
insertItem(_parentId : String, _child : XMLList) :
Boolean
{
var parentElement : XMLList =
this.findItem(_parentId);
// ---- Exit if we didnt find the parent
if (parentElement == null)
return false;
// ---- Add the child element to the parent's
children collection
parentElement.* += _child;
return true;
}
=============================================================
=============================================================
===== FUNCTION: findItem(_id, _xml)
=============================================================
public function findItem (_id :
String, _xml : XMLList) : XMLList
{
// ---- Check if the supplied element is the
one we're looking for
if ([EMAIL PROTECTED] == _id)
return _xml;
var
children : XMLList = _xml.element;
var result : XMLList = null;
for each (var x : XML in children)
{
// ---- Recurse, looking at children.
result = this.findItem(_id, new
XMLList(x));
// ---- Return the result if its not null,
ending the recursion
if (result != null)
return result;
}
return null;
}
=============================================================
Regards,
Graham Weldon
Tim Hoff wrote:
Hi Graham,
I'm not sure if it works, but have you tried this approach?
var myTreeData:ICollectionView = new XMLListCollection();
var myCursor:IViewCursor = myArrayCollection.createCursor();
myCursor.findFirst([EMAIL PROTECTED]:"9998"});
// maybe just Id?. According to the docs, this only works if the
collection is sorted.
myCursor.insert({label:"thing", id:"9999"});
// might be different syntax for XML
-TH
--- In flexcoders@yahoogroups.com,
"Bryan Choi" <[EMAIL PROTECTED]>
wrote:
>
> Hi Graham,
>
> As you can see that my english is not good.
>
> If I can tell you in english well, might be is not now in Korea.
>
> So I told you how many it'll help you...
>
> I am so sorry.
>
> However, I think that you can understand it, if you know that AS
3.0 syntax.
>
> Any way, I am sad and wanna talk in english well.
>
> Regards,
> Bryan Choi.
>
>
> ----- Original Message -----
> From: "Graham Weldon" <[EMAIL PROTECTED]>
> To: <flexcoders@yahoogroups.com>
> Sent: Thursday, May 25, 2006 9:59 AM
> Subject: Re: [flexcoders] XMLListCollection search [f2b3]
>
>
> >
> > Hi Bryan,
> >
> > Thanks for that link. Unfortunately I don't read Korean too well
(at all).
> > Do you know if there is an English translation for this
discussion, or
> > do you have some code samples that are commented in English?
> >
> > Regards,
> > Graham Weldon
> > \
> >
> >
> > Bryan Choi wrote:
> >
> >> Hi, Graham Weldon.
> >>
> >> I am a Korean.
> >>
> >> I explained it on my community.
> >>
> >> You can see from the url (
http://cafe.naver.com/flexcomponent/665
)
> >>
> >> Actually, I was helped flexcoders members.
> >>
> >> So I'll show you and many Korean.
> >>
> >> I don't know how many it'll help you to know it.
> >>
> >> Thank you,
> >> Bryan.
> >>
> >>
> >> ----- Original Message -----
> >> From: "Graham Weldon" <[EMAIL PROTECTED]>
> >> To: <flexcoders@yahoogroups.com>
> >> Sent: Thursday, May 25, 2006 9:05 AM
> >> Subject: [flexcoders] XMLListCollection search [f2b3]
> >>
> >>
> >> > Hi all,
> >> >
> >> > I'm wondering if anyone has had any experience or has some
samples for
> >> > searching an XMLListCollection for a particular item?
> >> > I have a nested structure of <element>'s, each having
an "id"
> >> attribute.
> >> > I would like to be able to do something like:
> >> >
> >> > var myXmlListCollection : XMLListCollection = new
XMLListCollection(
> >> ...
> >> > some data source ... );
> >> > var item : *** = findItem(myXmlListCollection,
'MyUniqueId');
> >> > trace (item.toString());
> >> >
> >> > I am unsure of the class type of variable "item"
in this
example. I
> >> want
> >> > to be able to add in an element using "item" as
the parent.
So the data
> >> > type used needs to allow this type of operation. The next
step will be
> >> > to add a child to this found item.
> >> >
> >> > Any thoughts?
> >> >
> >> > Regards,
> >> > Graham Weldon
> >> >
> >> >
> >> >
> >> > --
> >> > Flexcoders Mailing List
> >> > FAQ:
http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
> >> > Search Archives:
> >> http://www.mail-archive.com/flexcoders%40yahoogroups.com
> >> > Yahoo! Groups Links
> >> >
> >> >
> >> >
> >> >
> >> >
> >> >
> >> >
> >> >
> >>
> >> --
> >> Flexcoders Mailing List
> >> FAQ:
http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
> >> Search Archives: http://www.mail-archive.com/flexcoders%
40yahoogroups.com
> >>
> >>
> >>
> >> SPONSORED LINKS
> >> Web site design development
> >> <http://groups.yahoo.com/gads?
t=ms&k=Web+site+design+development&w1=Web+site+design+development&w2=
Computer+software+development&w3=Software+design+and+development&w4=M
acromedia+flex&w5=Software+development+best+practice&c=5&s=166&.sig=L
-4QTvxB_quFDtMyhrQaHQ>
> >> Computer software development
> >> <http://groups.yahoo.com/gads?
t=ms&k=Computer+software+development&w1=Web+site+design+development&w
2=Computer+software+development&w3=Software+design+and+development&w4
=Macromedia+flex&w5=Software+development+best+practice&c=5&s=166&.sig
=lvQjSRfQDfWudJSe1lLjHw>
> >> Software design and development
> >> <http://groups.yahoo.com/gads?
t=ms&k=Software+design+and+development&w1=Web+site+design+development
&w2=Computer+software+development&w3=Software+design+and+development&
w4=Macromedia+flex&w5=Software+development+best+practice&c=5&s=166&.s
ig=1pMBCdo3DsJbuU9AEmO1oQ>
> >>
> >> Macromedia flex
> >> <http://groups.yahoo.com/gads?
t=ms&k=Macromedia+flex&w1=Web+site+design+development&w2=Computer+sof
tware+development&w3=Software+design+and+development&w4=Macromedia+fl
ex&w5=Software+development+best+practice&c=5&s=166&.sig=OO6nPIrz7_EpZ
I36cYzBjw>
> >> Software development best practice
> >> <http://groups.yahoo.com/gads?
t=ms&k=Software+development+best+practice&w1=Web+site+design+developm
ent&w2=Computer+software+development&w3=Software+design+and+developme
nt&w4=Macromedia+flex&w5=Software+development+best+practice&c=5&s=166
&.sig=f89quyyulIDsnABLD6IXIw>
> >>
> >>
> >>
> >> ----------------------------------------------------------------
--------
> >> YAHOO! GROUPS LINKS
> >>
> >> * Visit your group "flexcoders
> >> <http://groups.yahoo.com/group/flexcoders>"
on the web.
> >>
> >> * To unsubscribe from this group,
send an email to:
> >> [EMAIL PROTECTED]
> >> <mailto:[EMAIL PROTECTED]?
subject=Unsubscribe>
> >>
> >> * Your use of Yahoo! Groups is
subject to the Yahoo! Terms
of
> >> Service <http://docs.yahoo.com/info/terms/>.
> >>
> >>
> >> ----------------------------------------------------------------
--------
> >>
> >
> >
> >
> > ------------------------ Yahoo! Groups Sponsor ------------------
--~-->
> > Get to your groups with one click. Know instantly when new email
arrives
> > http://us.click.yahoo.com/.7bhrC/MGxNAA/yQLSAA/nhFolB/TM
> > -----------------------------------------------------------------
---~->
> >
> > --
> > Flexcoders Mailing List
> > FAQ:
http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
> > Search Archives: http://www.mail-archive.com/flexcoders%
40yahoogroups.com
> > Yahoo! Groups Links
> >
> >
> >
> >
> >
> >
> >
> >
>
--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
SPONSORED LINKS
YAHOO! GROUPS LINKS