Sorry i will stop to ask that much in the forum and try myself but i have another problem.
. I would like to be able to delete a node according to his attribute "id" of the node "adverts". ?????
here is the xml script :
<page id="Page1">
<adverts id="0">
<adfile>file1</adfile>
<adwidth>1</adwidth>
<adheight>50</adheight>
<adposx>212</adposx>
<adposy>375</adposy>
</adverts>
<adverts id="1">
<adfile>file2</adfile>
<adwidth>1</adwidth>
<adheight>50</adheight>
<adposx>7</adposx>
<adposy>69</adposy>
</adverts>
<adverts id="2">
<adfile>file3</adfile>
<adwidth>1</adwidth>
<adheight>50</adheight>
<adposx>83</adposx>
<adposy>303</adposy>
</adverts>
</page>
</Pages>
I tried like this but it didnt work :
function deleteme(evt:MouseEvent):void {
var who_Id:int=evt.target.parent.parent.id; // just to get the id number
var who:String=evt.target.parent.parent.name;
this.removeChild(evt.target.parent.parent);
this.evt.target.parent.parent= null;
delete Pages.page.adverts.(@id==who_Id); //can change who_Id by a number for test
trace(Pages);
}
It could be a simple as:
delete xml.page.adverts[who_Id];
But once a node is deleted the number names would no longer match the node number.
So maybe you are looking for this:
var xml:XML =
<Pages>
<page id="Page1">
<adverts id="0">
<adfile>file1</adfile>
<adwidth>1</adwidth>
<adheight>50</adheight>
<adposx>212</adposx>
<adposy>375</adposy>
</adverts>
<adverts id="1">
<adfile>file2</adfile>
<adwidth>1</adwidth>
<adheight>50</adheight>
<adposx>7</adposx>
<adposy>69</adposy>
</adverts>
<adverts id="2">
<adfile>file3</adfile>
<adwidth>1</adwidth>
<adheight>50</adheight>
<adposx>83</adposx>
<adposy>303</adposy>
</adverts>
</page>
</Pages>
var who_Id:int=1;
for (var i:Number = 0; i < xml.page.adverts.length(); i++) {
if (xml.page.adverts[i].@id==String(who_Id)) {
delete xml.page.adverts[i];
}
}
trace(xml);
North America
Europe, Middle East and Africa
Asia Pacific