HOW TO: Delete an XML node using E4X

While creating a sample application for some class content the other day, I ran into an XML/E4X situation that I’d never encountered before. It is pretty basic – deleting a node from XML. How does one do it? With the delete keyword of course!

For example:
[as]var myXML:XML =

Hamburger
Fries
Med. Soda
Lg. Soda
;

// Delete the Med. Soda node

// Output the XML
trace( myXML.toXMLString() );

// Result
//
// Hamburger
// Fries
// Med. Soda
// Lg. Soda
//

delete myXML.item[2];

// Output the edited XML
trace( myXML.toXMLString() );

// Result
//
// Hamburger
// Fries
// Lg. Soda
//
[/as]
Man, E4X is so simple!

http://www.thekuroko.com/wp-content/plugins/downloads-manager/img/icons/winzip.gif download: Delete Node Example (4.78KB)
added: 04/09/2009
clicks: 896
description: Code source (.FLA) for delete XML node using E4X in ActionScript 3 sample

Comments

  1. Insane says:

    noo, really ?? -_-

  2. jccrosby says:

    Yeah really. The post might be helpful to someone – unlike your comment. -_-

Trackbacks

  1. [...] Saved by theacademy on Tue 30-12-2008 360Flex E4X Saved by nrutman on Tue 30-12-2008 HOW TO: Delete an XML node using E4X Saved by gammasigma on Thu 25-12-2008 E4X Introduction Saved by Xelanderthomas on Mon 15-12-2008 [...]

Speak Your Mind

*