this isnt exactly a clean and optimized code, but it
works. just tweak it according to your needs. It
accepts both xml and xmllist. heck it will even accept
any object so long as there is a length() method in
it, however in that case, it will just return the
original object. let me know if it helped.. or if you
encounter any problems. Cheers! :)

public function
deleteDescendantsByName(a:*,nodeName:String):*{
                        
                        var r:XMLList=null;
                                        
                        if (a.length()>=1){
                                r = new XMLList();                      
                                for (var i:int=0;i<a.length(); i++){
                                        
                                        if (a[i].name().localName!=nodeName){
                                                if 
(a[i].descendants(nodeName).length()==0){
                                                        r+=a[i];        
                                                }else{
                                                        var
t:XMLList=deleteDescendantsByName(a[i].children(),nodeName);
                                                        a[i].setChildren(t);
                                                        r+=a[i];
                                                }
                                        
                                        }
                          }
                }
                return r;
        }






--- iondisc <[EMAIL PROTECTED]> wrote:

> 
> Does anyone know a way to suppress/remove specific
> nodes from an
> XML/XMLList or XMLCollection?
> 
> I have say this XML:
> 
> <root>
>       <level>
>             <detail>
>             </detail>
>      </level>
>       <level>
>             <detail>
>             </detail>
>      </level>
> </root>
> 
> I want to make a copy of this XML (could be either
> of the three types of
> XML objects) and remove the <detail> nodes from
> every node no matter
> what hiarchy they are in.
> 
> Thanks in advance,
> Dustyn Eskelson
> 
> 
> 
> 
> 



 
____________________________________________________________________________________
Do you Yahoo!?
Everyone is raving about the all-new Yahoo! Mail beta.
http://new.mail.yahoo.com

Reply via email to