something like:

delete x1.item[prop.childIndex()];

?

Peter

On 8/28/07, generalxxaxx <[EMAIL PROTECTED]> wrote:
>
>   Using the code below I can remove a node from the x1:XML object.
> However, using the incremented count as the index value for the node
> in the XML makes me nervous.
>
> Is there a better way to get the index value of a node so that one can
> use the delete?
>
> var x1:XML = <x1>
> <item>
> <a id = "52">AYY</a>
> </item>
> <item>
> <a>AYY 2 </a>
> </item>
> <item>
> <b>BEE</b>
> </item>
> <item>
> <c>CEE</c>
> </item>
> </x1>;
> trace(x1.toXMLString());
> var count:Number = 0;
> for each (var prop:XML in x1.item) {
> trace(count.toString() + ": "+prop.toXMLString());
> if (prop.b=="BEE") {
> trace("Found BEE");
> delete x1.item[count];
> } else {
> count++;
> }
> }
> trace(x1.toXMLString());
>
> Output:
> <x1>
> <item>
> <a id="52">AYY</a>
> </item>
> <item>
> <a>AYY 2</a>
> </item>
> <item>
> <b>BEE</b>
> </item>
> <item>
> <c>CEE</c>
> </item>
> </x1>
>
> 0: <item>
> <a id="52">AYY</a>
> </item>
> 1: <item>
> <a>AYY 2</a>
> </item>
> 2: <item>
> <b>BEE</b>
> </item>
> Found BEE
> 2: <item>
> <c>CEE</c>
> </item>
>
> <x1>
> <item>
> <a id="52">AYY</a>
> </item>
> <item>
> <a>AYY 2</a>
> </item>
> <item>
> <c>CEE</c>
> </item>
> </x1>
>
>  
>

Reply via email to