Inserting a node after an existing one
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="tryme()">
<mx:XML id="usersXML">
<root>
<users>
<user id="1">
<firstname>A</firstname>
<lastname>A</lastname>
</user>
<user id="2">
<firstname>H</firstname>
<lastname>H</lastname>
</user>
</users>
</root>
</mx:XML>
<mx:Script>
[Bindable]
public var infoString:String = "";
public function tryme():void
{
var newUser:XML =
<user id="3">
<firstname>A</firstname>
<lastname>A</lastname>
</user>;
usersXML.users.insertChildAfter(usersXML.users.user[0],newUser);
}
</mx:Script>
<mx:TextArea text="{infoString}" width="250" height="100" />
</mx:Application>
Related examples in the same category