Copy link to clipboard
Copied
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 :
I tried like this but it didnt work :
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</a
...Copy link to clipboard
Copied
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.@id==String(who_Id)) {
delete xml.page.adverts;
}
}
trace(xml);
Copy link to clipboard
Copied
thanks a lot . and MERY CHRISMAS