Tutorials to .com

Tutorials to .com » Website » Flash » AS3's XML delete node

AS3's XML delete node

Print View , by: iSee ,Total views: 13 ,Word Count: 222 ,Date: Wed, 19 Aug 2009 Time: 10:09 AM

E4X specification deleteByIndex definition and method used to delete to delete a specific xml node, but in the current version of the ActionScript 3.0 implementation does not achieve this in two ways.
The Help files in AS3 also did not mention how to delete an xml node.

One way is to delete oneXMLNode;

We do not know what other way to remove xml nodes. Have read an article. The principle is to re-construct a XML object, this object in the structure when you want to delete the exclusion of that node.
private function deleteByIndex (xmlNode: XML, index: Number): XML (
var newStr: String ='';
newStr +='<'+ xmlNode.localName ();
for each (var att: XML in xmlNode.attributes ()) (
newStr + = '' + att.localName ()+'="'+ att.toString ()+'"';
newStr +='>';
var i: Number = 0;
for each (var node: XML in xmlNode.children ()) (
if (i! = index)
newStr + = node.toXMLString ();
i + +;
newStr +='</'+ xmlNode.localName ()+'/>';
return new XML (newStr);

Adobe Flash Articles

Can't Find What You're Looking For?

Rating: Not yet rated


No comments posted.