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 = 'parentchild id=a /child id=b /child id=a /child id=b //parent'; var xml:XML = new XML(s); delete xml.child; Bug or feature? Who knows.. regards, Muzak - Original Message - From: liutoday today...@hotmail.com To: flashcoders@chattyfig.figleaf.com 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 parent child id=a / child id=b / child id=a / child id=b / /parent How would I find and delete any child 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
Thanks guys, those were both very helpful. On Mon, Mar 9, 2009 at 3:35 AM, Muzak p.ginnebe...@telenet.be 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 = 'parentchild id=a /child id=b /child id=a /child id=b //parent'; var xml:XML = new XML(s); delete xml.child; Bug or feature? Who knows.. regards, Muzak - Original Message - From: liutoday today...@hotmail.com To: flashcoders@chattyfig.figleaf.com 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 parent child id=a / child id=b / child id=a / child id=b / /parent How would I find and delete any child 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
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 = 'parentchild id=a /child id=b /child id=a /child id=b //parent'; 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: parent child id=a/ child id=b/ child id=a/ child id=b/ /parent -- elements: child id=a/ child id=a/ -- after: parent child id=a/ child id=a/ /parent regards, Muzak - Original Message - From: Joel Stransky j...@stranskydesign.com To: Flash Coders List flashcoders@chattyfig.figleaf.com 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 parent child id=a / child id=b / child id=a / child id=b / /parent How would I find and delete any child who's id is b ? -- --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
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 parent child id=a / child id=b / child id=a / child id=b / /parent How would I find and delete any child 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