Re: [Flashcoders] find and delete XML nodes
Thanks guys, those were both very helpful. On Mon, Mar 9, 2009 at 3:35 AM, Muzak wrote: > >> delete xml.child.(@id=="b"); >> >> > You might wanna try that first.. > > TypeError: Error #1119: Delete operator is not supported with operand of > type XMLList. > "delete" works as long as the XMLList is not retrieved using an expression, > which in this case it is: (@id == "b"). > > So the following works (and deletes all elements): > > var s:String = ' />'; > var xml:XML = new XML(s); > delete xml.child; > > Bug or feature? Who knows.. > > regards, > Muzak > > - Original Message ----- From: "liutoday" > To: > Sent: Monday, March 09, 2009 5:28 AM > Subject: RE: [Flashcoders] find and delete XML nodes > > > >> >> >> Date: Sun, 8 Mar 2009 23:38:17 -0400 >>> From: j...@stranskydesign.com >>> To: flashcoders@chattyfig.figleaf.com >>> Subject: [Flashcoders] find and delete XML nodes >>> >>> I have some xml nodes where I need to evaluate their attributes and >>> delete >>> them if they meet certain criteria. It's probably simple but its late and >>> brain fatigue is setting in. >>> >>> Say I had this node >>> >>> >>> >>> >>> >>> >>> >>> >>> How would I find and delete any who's id is "b" ? >>> -- >>> --Joel Stransky >>> stranskydesign.com >>> ___ >>> >> >> >> delete xml.child.(@id=="b"); >> >> > ___ > Flashcoders mailing list > Flashcoders@chattyfig.figleaf.com > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders > -- --Joel Stransky stranskydesign.com ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] find and delete XML nodes
delete xml.child.(@id=="b"); You might wanna try that first.. TypeError: Error #1119: Delete operator is not supported with operand of type XMLList. "delete" works as long as the XMLList is not retrieved using an expression, which in this case it is: (@id == "b"). So the following works (and deletes all elements): var s:String = ''; var xml:XML = new XML(s); delete xml.child; Bug or feature? Who knows.. regards, Muzak - Original Message - From: "liutoday" To: Sent: Monday, March 09, 2009 5:28 AM Subject: RE: [Flashcoders] find and delete XML nodes Date: Sun, 8 Mar 2009 23:38:17 -0400 From: j...@stranskydesign.com To: flashcoders@chattyfig.figleaf.com Subject: [Flashcoders] find and delete XML nodes I have some xml nodes where I need to evaluate their attributes and delete them if they meet certain criteria. It's probably simple but its late and brain fatigue is setting in. Say I had this node How would I find and delete any who's id is "b" ? -- --Joel Stransky stranskydesign.com ___ delete xml.child.(@id=="b"); ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
RE: [Flashcoders] find and delete XML nodes
> Date: Sun, 8 Mar 2009 23:38:17 -0400 > From: j...@stranskydesign.com > To: flashcoders@chattyfig.figleaf.com > Subject: [Flashcoders] find and delete XML nodes > > I have some xml nodes where I need to evaluate their attributes and delete > them if they meet certain criteria. It's probably simple but its late and > brain fatigue is setting in. > > Say I had this node > > > > > > > > > How would I find and delete any who's id is "b" ? > -- > --Joel Stransky > stranskydesign.com > ___ delete xml.child.(@id=="b"); _ MSN安全保护中心,免费修复系统漏洞,保护MSN安全! http://im.live.cn/safe/ ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] find and delete XML nodes
One way to do it is to look for the child elements which id is *not* "b". Then replace the original child elements with the new ones, or in other words, set the remaining elements as the children of the parent: var s:String = ''; var xml:XML = new XML(s); trace("before: ", xml.toXMLString()); trace("--"); var elements:XMLList = xml.child.(@id != "b"); trace("elements: ", elements.toXMLString()); trace("--"); xml.setChildren(elements); trace("after: ", xml.toXMLString()); //output: before: -- elements: -- after: regards, Muzak - Original Message - From: "Joel Stransky" To: "Flash Coders List" Sent: Monday, March 09, 2009 4:38 AM Subject: [Flashcoders] find and delete XML nodes I have some xml nodes where I need to evaluate their attributes and delete them if they meet certain criteria. It's probably simple but its late and brain fatigue is setting in. Say I had this node How would I find and delete any who's id is "b" ? -- --Joel Stransky stranskydesign.com ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
[Flashcoders] find and delete XML nodes
I have some xml nodes where I need to evaluate their attributes and delete them if they meet certain criteria. It's probably simple but its late and brain fatigue is setting in. Say I had this node How would I find and delete any who's id is "b" ? -- --Joel Stransky stranskydesign.com ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders